catalyst / moodle-tool_lockstats

Moodle cron / task API lock statistics admin tool
https://moodle.org/plugins/tool_lockstats
6 stars 13 forks source link

Optimise get_recent_history SQL #75

Open dmitriim opened 5 years ago

dmitriim commented 5 years ago

On big instances we have noticed that SQL from get_recent_history method takes a long time to run + puts some load on DB CPU.

We need to optimise this SQL

brendanheywood commented 4 years ago

Fixed in https://github.com/catalyst/moodle-tool_lockstats/issues/92

Peterburnett commented 4 years ago

Im gonna reopen this one, it may not be fixed by #92. This query should be improveable by removing the subquery and instead doing something like: SELECT * FROM {tool_lockstats_history} WHERE taskid = :taskid ORDER BY id DESC LIMIT 1