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

后端 未结 4 1007
[愿得一人]
[愿得一人] 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:21

    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:

    1. SHOW PROCESSLIST
    2. Find all connections with a query time larger than your maximum desired time
    3. Run KILL [process id] for each of those processes

提交回复
热议问题