delayed_job icon indicating copy to clipboard operation
delayed_job copied to clipboard

DelaydJob SQL request are very slow

Open mikhailov opened this issue 14 years ago • 4 comments

NewRelic RPM show me the DelaydJob SQL request as very slow. MySQL Slow Query Log does the same. What exactly column should be indexed? single or multiple columns indexes? Does anybody do an analysis?

mikhailov avatar Mar 18 '10 05:03 mikhailov

I have found an interested article, Tobi, please take a look, can it help? http://www.elevatedcode.com/articles/2009/11/04/speeding-up-delayed-job/

mikhailov avatar Mar 18 '10 05:03 mikhailov

You need this. http://github.com/collectiveidea/delayed_job/commit/c743446a31fe5683544b78e9bf86dec371923b38

Depending on which database you use there are different solutions:

  • with MySQL you should reverse priority order and create a composite[:priority, :run_at],
  • with Postgres you should create a composite index with different order on both columns priority DESC, run_at ASC.

Hope this helps.

BTW I am using the former "method" with thousands of jobs in table with no problem.

jsuchal avatar Mar 18 '10 07:03 jsuchal

Great thanks! But I'm using of gem instead of plugin. Is it possible to pull request to official version?

mikhailov avatar Mar 18 '10 07:03 mikhailov

You can also use it as a gem. Just look at README http://github.com/collectiveidea/delayed_job#readme

jsuchal avatar Mar 18 '10 07:03 jsuchal