I'm looking for a way to limit the max running time of a query on mysql server. I figured this could be done through the my.cnf
configuration file, but couldn't find anything relevant in the docs. Anyone knows if this could be done? thanks.
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
- mySQL alter table on update, current timestamp
http://mysqlserverteam.com/server-side-select-statement-timeouts/
Interesting upgrade. I will check it:
"MySQL 5.7.4 introduces the ability to set server side execution time limits, specified in milliseconds, for top level read-only SELECT statements".
You could use a query as follows:
UPDATE: You should use max_execution_time instead.
MAX_STATEMENT_TIME was renamed to max_execution_time in MySQL 5.7.8. http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_execution_time
In the meantime the Twitter team released their changes to MySQL which implements this:
- Reduce unnecessary work through improved server-side statement timeout support. This allows the server to proactively cancel queries that run longer than a millisecond-granularity timeout.
See http://engineering.twitter.com/2012/04/mysql-at-twitter.html and https://github.com/twitter/mysql/wiki/Statement-Timeout
There is no way to specify a maximum run time when sending a query to the server to run.
However, it is not uncommon to have a cron job that runs every second on your database server, connecting and doing something like this: