Pause a MySQL query with sleep
Snippet
Posted by kitt at 23:17 on 16 January 2010
For MySQL > 5.0.12, execution of a series of queries can be delayed / paused by using SELECT SLEEP(), which is useful when a previous query needs to be paused, say, when a slave is reconnecting to a master.
-- delay a query by one second SELECT SLEEP(1); -- delay a series of queries by a 30 seconds SELECT SLEEP(30); -- stop the slave, skip the error SQL, start the slave, pause a second, then check the slave status STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; START SLAVE; SELECT SLEEP(1); SHOW SLAVE STATUS;
Source:
Comments
If you use DO SLEEP(x) it
If you use DO SLEEP(x) it will be possible to use it in places where you cannot have select statements. Also you do not get unnecessary outputs from the SELECT SLEEP() statements.