pg_sleep_for()

A system function for sleeping for the specified interval

pg_sleep_for() is a system function for causing the connected backend to sleep for the specified interval.

pg_sleep_for() was added in PostgreSQL 9.4.

Usage

pg_sleep_for ( interval ) → 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

postgres=# SELECT clock_timestamp(), pg_sleep_for('10 seconds'), clock_timestamp();
        clock_timestamp        | pg_sleep_for |        clock_timestamp
-------------------------------+--------------+-------------------------------
 2021-02-02 12:29:13.672416+01 |              | 2021-02-02 12:29:23.681761+01
(1 row)

Categories

System function

See also

pg_sleep(), pg_sleep_until()