Skip to content

Instantly share code, notes, and snippets.

@mcollina
Created February 5, 2011 10:50
Show Gist options
  • Save mcollina/812364 to your computer and use it in GitHub Desktop.
Save mcollina/812364 to your computer and use it in GitHub Desktop.
A migration to improve Delayed Job performance when runned with Delayed::Worker.destroy_failed_jobs = false.
class ImproveDelayedJobsIndex < ActiveRecord::Migration
def self.up
remove_index :delayed_jobs, :name => "delayed_jobs_priority"
add_index :delayed_jobs, [:failed_at, :priority, :run_at], :name => 'delayed_jobs_priority'
end
def self.down
remove_index :delayed_jobs, :name => "delayed_jobs_priority"
add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment