Is it possible to configure MySQL so that it has some kind of execution limit similar to PHP’s max execution time so that if a Query is taking longer than – say – 30 seconds, it automatically gets killed?
I just ran a poorly written query on phpMyAdmin as a test and it ate up all the CPU and killed my site for about 15 minutes…had to restart MySQL to bring my site back.
Any ideas?
MySQL doesnt have this time limit functionality that PHP does. Some options are you can mess with your hit_counter variable or join_table size in my.conf, or even disallow persistent connections. But to really get the functionality you desire, you will have to write your own polling daemon to check MySQL and make sure nothing is acting up.
User x9sim9 on StackOverflow has volunteered the following PHP script that does just this — though you could code it in any other scripting language. Have your crontab execute it frequently (every minute or so).
Please see the rest of the associated answer here: Anyway to Limit MySQL Query Execution time?