title: Production (heroku, postgres) #find_in_batches query running at long intervals
body: <p>I've got a job (which is queued up using DelayedJob) for deleting med-large amounts of records.  On production, the job is running extremely slowly, deleting around 1200 records per hour.  At first, I just destroyed and re-ran the job, then ran heroku restart (in case it was running into a memory leak issue or something), but nothing changed.</p>
  
  <p>Looking at the logs, I noticed that each batch was running exactly 4 minutes and 40 or 41 seconds after the last one, but I can't find any setting anywhere that would be responsible for this.  When I run the same job in development, it deleted all 100k records in just a minute or two.  </p>
  
  <p>Is there some setting for this that I'm missing, or something else I'm overlooking?  Here's the relevant part of the job code in case it provides any clues.  </p>
  
  <pre><code>total_deleted = 0
  Record.where(...).includes(...).find_in_batches(batch_size: 100) do |group|
    Record.transaction do
      group.each do |record|
        record.destroy
      end
  
      total_deleted += group.size
      percentage = (total_deleted.to_f / total.to_f * 100).round
      self.update_attribute(:details, "Deleted #{total_deleted} of #{total} (#{percentage}%)")
    end
  end
  </code></pre>