Suggestion: Add MAX_EXECUTION_TIME hint to queries
-
Yesterday we noticed that all our wordpress sites that were sharing a database were running very slow and often stopped responding so it timed out. After hours of debugging we noticed that the database had very many running processes even though none of the sites were really operational.
It turned out that one of the sites that uses the Popular Posts plugin had over 100 database processes running all of them running a query starting withSELECT p.ID AS id, p.post_title AS title, p.post_author AS uid FROM 'wp_popularpostssummary' v LEFT
some of the oldest processes were over 1 hour old. We had to disable the plugin and manually kill every process to make things run again. It seems one of them somehow deadlocked all the others so that it eventually consumed all available connections. After we killed the one of the hundreds of processes, it seemed to start clearing itself. Not sure how it happened, but when we tried to re-activate the plugin it seemed to start filling up the process list, because the queries seems to be very long running even though it eventually finishes.We are using mysql v 5.7+ so it would have supported MAX_EXECUTION_TIME hint.
If you added a max execution time hint like this (1 second in the example below), I would feel a bit more comfortable re-activating the plugin:// Finally, build the query $query = "SELECT /*+ MAX_EXECUTION_TIME(1000) */ {$fields} FROM ...
See:
https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html#optimizer-hints-execution-timeI guess if I configured data sampling, it would spam the database less, but I’m still concerned that the queries seems to run very long. Or do you think it’s just long running because it’s spamming the database too fast?
- The topic ‘Suggestion: Add MAX_EXECUTION_TIME hint to queries’ is closed to new replies.