Home > Blockchain >  How to chnage default timeout duration in MySQL
How to chnage default timeout duration in MySQL

Time:06-15

I just want to how can I change the global timeout duration and how can I test it.

I've some queries that I believe to change the defaul timeout duration, like;

SET GLOBAL max_execution_time = 4;

I think if I set max_execution_time = 4 , and if my query will executing in 5 sec I 'll get timeout error. I just tried some queries for testing. I wondered if I apply to default imeout to 4 sec;

DO SLEEP(5);

SELECT SLEEP(5);

also I found a query for test the timeout duration that is;

WAITFOR DELAY (5);

but didn't work (code throw an error).

After I tried thoose are, I didn't get the timout error. I expected to get it.

CodePudding user response:

Your problem is that in mysql is SELECT SLEEP(5); while in sql is WAITFOR DELAY (5); that's why it doesn't work.

SET GLOBAL max_execution_time = 4;
SELECT SLEEP(5);

Example : https://www.db-fiddle.com/f/3PnzHErrf2fZFGZY67K12X/440

CodePudding user response:

First of all, max_execution_time uses milliseconds as its base unit while the sleep() function use seconds . Besides, SET GLOBAL affect the global scope but not the current session. If you want to test it, set the variable value for the session as well.

set global max_execution_time = 4000;
set session max_execution_time = 4000;
select sleep(10); 

The last statement will end as soon as 4 seconds elapses.

  • Related