2

How do I change the limit in execution time for queries above 30'' ?

If I try

SET MAX_EXECUTION_TIME = 3600

I receive

error 1193 "unknown system variable MAX_EXECUTION_TIME"

I'm using MySQLWorkbench and mysql version 5.6.36

Carlo
  • 395
  • 1
  • 8
  • 22

3 Answers3

3

If you are running MySQL 5.7.8 or later, you can use

SET SESSION MAX_EXECUTION_TIME = 3600

to set it for the session, or

SET GLOBAL MAX_EXECUTION_TIME = 3600

to set it globally. Note that this ability was first introduced in MySQL 5.7.4 as max_statement_time; in 5.7.8 the name was changed to max_execution_time.

Nick
  • 138,499
  • 22
  • 57
  • 95
0

If you have MySQL 5.7 or later, this parameter MAX_EXECUTION_TIME is for long running queries.

At first check the current value by running this query

> SELECT @@GLOBAL.MAX_EXECUTION_TIME @@SESSION.MAX_EXECUTION_TIME;

Then set it according to your needs.

> SET SESSION MAX_EXECUTION_TIME=3600;
> SET GLOBAL MAX_EXECUTION_TIME=3600;
Amine KOUIS
  • 1,686
  • 11
  • 12
  • I receive error 1193 12:12:05 SELECT @@GLOBAL.MAX_EXECUTION_TIME @@SESSION.MAX_EXECUTION_TIME Error Code: 1193. Unknown system variable 'MAX_EXECUTION_TIME' 0.0087 sec – Carlo Feb 08 '19 at 12:12
  • look here, maybe you need to create a stored procedure https://stackoverflow.com/questions/54005466/global-query-timeout-in-mysql-5-6 or to have a cron job https://stackoverflow.com/questions/4794747/mysql-can-i-limit-the-maximum-time-allowed-for-a-query-to-run or you can do an upgrade to MySQL 5.7 – Amine KOUIS Feb 08 '19 at 12:35
  • It dosen't work in my case, error occurred while I run this with root user: [42000][1227] Access denied; you need (at least one of) the SUPER privilege(s) for this operatio – AnonymousX Jan 06 '22 at 07:04
0

You can try setting it at query level, like

SELECT +MAX_EXECUTION_TIME(3600) * FROM T

MAX_EXECUTION_TIME(N) applied to read only select statements.

subodh
  • 6,136
  • 12
  • 51
  • 73