MySQL – Wait For Seconds Using SELECT SLEEP()

MySQL - Wait For Seconds Using SELECT SLEEP() selectsleep-800x784 I love my job as SQL Performance Tuning Expert as I get to learn so many new things every single day when I work with my clients at Comprehensive Database Performance Health Check. Recently my client asked me if there is the equivalent command of WAIT FOR of SQL Server in MySQL. Of course, there is and a very simple one.

If you want to wait for 5 seconds in SQL Server code, you will run the following command:

WAITFOR DELAY '00:00:05';

Now the similar code in MySQL can be written in two different ways.

Method 1:


Method 2:


I personally prefer method 2 over method 1. This kind of function can be helpful to test asynchronous queries as well as slow running queries.

In any case, let me know if you have used this kind of function in your production or not. If yes, I would like to know what was the purpose you used this one for. Additionally, leave a comment to this blog post if you want to learn anything new and I will be happy to share that with you.

Let me summarize how you can stay in touch with me if you want my content every single day.

Reference: Pinal Dave (

MySQL, SQL Scripts
Previous Post
SQL Authority 15 Years of Blogging and Upcoming Changes
Next Post
SQL SERVER – List Databases Where User Has DB Access

Related Posts

Leave a Reply