How to set a maximum execution time for a mysql query?

后端 未结 5 2149
萌比男神i
萌比男神i 2020-11-27 21:20

I would like to set a maximum execution time for sql queries like set_time_limit() in php. How can I do ?

5条回答
  •  旧巷少年郎
    2020-11-27 22:01

    You can find the answer on this other S.O. question:

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

    a cron job that runs every second on your database server, connecting and doing something like this:

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

提交回复
热议问题