- The following function is available to delay execution of the server
+ The following functions are available to delay execution of the server
process:
pg_sleep(seconds)
+pg_sleep_for(interval>)
+pg_sleep_until(timestamp with time zone>)
pg_sleep makes the current session's process
sleep until seconds seconds have
elapsed. seconds is a value of type
double precision>, so fractional-second delays can be specified.
+ pg_sleep_for is a convenience function for larger
+ sleep times specified as an interval>.
+ pg_sleep_until is a convenience function for when
+ a specific wake-up time is desired.
For example:
SELECT pg_sleep(1.5);
+SELECT pg_sleep_for('5 minutes');
+SELECT pg_sleep_until('tomorrow 03:00');
The effective resolution of the sleep interval is platform-specific;
0.01 seconds is a common value. The sleep delay will be at least as long
as specified. It might be longer depending on factors such as server load.
+ In particular, pg_sleep_until is not guaranteed to
+ wake up exactly at the specified time, but it will not wake up any earlier.
Make sure that your session does not hold more locks than necessary
- when calling pg_sleep. Otherwise other sessions
- might have to wait for your sleeping process, slowing down the entire
- system.
+ when calling pg_sleep or its variants. Otherwise
+ other sessions might have to wait for your sleeping process, slowing down
+ the entire system.
DESCR("list all files in a directory");
DATA(insert OID = 2626 ( pg_sleep PGNSP PGUID 12 1 0 0 0 f f f f t f v 1 0 2278 "701" _null_ _null_ _null_ _null_ pg_sleep _null_ _null_ _null_ ));
DESCR("sleep for the specified time in seconds");
+DATA(insert OID = 3935 ( pg_sleep_for PGNSP PGUID 14 1 0 0 0 f f f f t f v 1 0 2278 "1186" _null_ _null_ _null_ _null_ "select pg_catalog.pg_sleep(extract(epoch from pg_catalog.now() operator(pg_catalog.+) $1) operator(pg_catalog.-) extract(epoch from pg_catalog.now()))" _null_ _null_ _null_ ));
+DESCR("sleep for the specified interval");
+DATA(insert OID = 3936 ( pg_sleep_until PGNSP PGUID 14 1 0 0 0 f f f f t f v 1 0 2278 "1184" _null_ _null_ _null_ _null_ "select pg_catalog.pg_sleep(extract(epoch from $1) operator(pg_catalog.-) extract(epoch from pg_catalog.now()))" _null_ _null_ _null_ ));
+DESCR("sleep until the specified time");
DATA(insert OID = 2971 ( text PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 25 "16" _null_ _null_ _null_ _null_ booltext _null_ _null_ _null_ ));
DESCR("convert boolean to text");