pg_sleep()

A system function for sleeping for the specified number of seconds

pg_sleep() is a system function for causing the connected backend to sleep for the specified number of seconds.

pg_sleep() was added in PostgreSQL 8.2.

Usage

pg_sleep ( double precision  ) → returns NULL

The documentation notes the following caveats:

  • the minimum sleep interval is platform-dependent and is typically 0.01 seconds
  • the sleep delay will always be at least the value specified, but may be longer under some circumstances

Change history

Examples

Basic execution of pg_sleep():

postgres=# SELECT pg_sleep(1);
 pg_sleep
----------

(1 row)

Time: 1001.172 ms (00:01.001)

The sleep duration can be specified as fractions of a second, e.g.:

postgres=# SELECT pg_sleep(0.5);
 pg_sleep
----------

(1 row)

Time: 500.770 ms

Categories

System catalogue

See also

pg_sleep_for(), pg_sleep_until()