Outdated Version

You are viewing an older version of this section. View current production version.

SLEEP

Halts execution of the thread for the given number of seconds.

Syntax

SLEEP ( seconds )

Arguments

  • seconds: the number of seconds (or fraction) to sleep the thread.

Return type

Returns an integer. Specifically, SLEEP() returns the number 0 if it returns normally without interruption. If the query that is being halted is killed or times out, SLEEP() returns the number 1.

Examples

This function is useful mainly for debugging and measurement purposes, e.g., to make sure a list of queries runs at certain intervals.

select now(); select sleep(10); select now();
+---------------------+
| now()               |
+---------------------+
| 2015-03-02 23:22:25 |
+---------------------+

+-----------+
| sleep(10) |
+-----------+
|         0 |
+-----------+

+---------------------+
| now()               |
+---------------------+
| 2015-03-02 23:22:35 |
+---------------------+