jamesrwhite / minicron

🕰️ Monitor your cron jobs
GNU General Public License v3.0
2.34k stars 154 forks source link

Optimize jobs page sql query #221

Closed Rido closed 7 years ago

Rido commented 8 years ago

First I want to thank you for the latest update. It has some great new features! :+1:

Today I noticed that the Jobs page is loading slowly. At this moment we have +- 100k executions in the database. I ran the minicron server in debug mode and I got this from the debug information:

D, [2016-04-11T10:08:33.539790 #30272] DEBUG -- :   Minicron::Hub::Execution Load (276.5ms)  SELECT `executions`.* FROM `executions` WHERE `executions`.`job_id` IN (20, 19, 18, 14, 13, 12, 11, 10, 9, 6, 5)
D, [2016-04-11T10:08:48.699620 #30272] DEBUG -- :    (2.0ms)  SELECT COUNT(*) FROM `executions` WHERE `executions`.`job_id` = 20

As you can see it takes +-15 seconds to load the jobs page.

Maybe it's an idea to add a counter column to the table jobs and each time the job has run you increase this value.

jamesrwhite commented 8 years ago

Sounds like a sensible idea, thanks!

jamesrwhite commented 7 years ago

This will ship in 1.0, thanks!