0

Is there any configuration setting using which long running query can be killed automatically in mysql?

Shadow
  • 32,277
  • 10
  • 49
  • 61
Bhupendra Pandey
  • 338
  • 2
  • 16
  • https://stackoverflow.com/questions/46154701/automatically-kill-long-running-queries-mysql-apache-tomcat-datasource – Zeljka Jan 29 '19 at 10:02

1 Answers1

2

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
  • 497
  • 2
  • 5
  • 22