Is there any configuration setting using which long running query can be killed automatically in mysql?
Asked
Active
Viewed 3,549 times
0
-
https://stackoverflow.com/questions/46154701/automatically-kill-long-running-queries-mysql-apache-tomcat-datasource – Zeljka Jan 29 '19 at 10:02
1 Answers
3
yes you can ! There is two ways of doing it.
In query
It sets a timeout in milliseconds.
SELECT /*+ MAX_EXECUTION_TIME(1000) */ status, count(*) FROM articles GROUP BY status ORDER BY status;
With server variables
SET SESSION MAX_EXECUTION_TIME=2000;
SET GLOBAL MAX_EXECUTION_TIME=2000;
These set a session-wide and global timeout.
I took the answer from this website.
I hope it helped.

Alexis Philip
- 517
- 2
- 5
- 23