MySQL - can I limit the maximum time allowed for a query to run?

后端 未结 4 1024
[愿得一人]
[愿得一人] 2020-11-27 19:39

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\

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 20:13

    You could use a query as follows:

    SELECT MAX_STATEMENT_TIME=1000 * FROM table;
    

    UPDATE: You should use max_execution_time instead.

    SELECT /*+ MAX_EXECUTION_TIME(1000)*/ * FROM table;
    

    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

提交回复
热议问题