@@ -7664,20 +7664,28 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT
76647664 </indexterm>
76657665
76667666 <para>
7667- The following function is available to delay execution of the server
7667+ The following functions are available to delay execution of the server
76687668 process:
76697669<synopsis>
76707670pg_sleep(<replaceable>seconds</replaceable>)
7671+ pg_sleep_for(<type>interval</>)
7672+ pg_sleep_until(<type>timestamp with time zone</>)
76717673</synopsis>
76727674
76737675 <function>pg_sleep</function> makes the current session's process
76747676 sleep until <replaceable>seconds</replaceable> seconds have
76757677 elapsed. <replaceable>seconds</replaceable> is a value of type
76767678 <type>double precision</>, so fractional-second delays can be specified.
7679+ <function>pg_sleep_for</function> is a convenience function for larger
7680+ sleep times specified as an <type>interval</>.
7681+ <function>pg_sleep_until</function> is a convenience function for when
7682+ a specific wake-up time is desired.
76777683 For example:
76787684
76797685<programlisting>
76807686SELECT pg_sleep(1.5);
7687+ SELECT pg_sleep_for('5 minutes');
7688+ SELECT pg_sleep_until('tomorrow 03:00');
76817689</programlisting>
76827690 </para>
76837691
@@ -7686,15 +7694,17 @@ SELECT pg_sleep(1.5);
76867694 The effective resolution of the sleep interval is platform-specific;
76877695 0.01 seconds is a common value. The sleep delay will be at least as long
76887696 as specified. It might be longer depending on factors such as server load.
7697+ In particular, <function>pg_sleep_until</function> is not guaranteed to
7698+ wake up exactly at the specified time, but it will not wake up any earlier.
76897699 </para>
76907700 </note>
76917701
76927702 <warning>
76937703 <para>
76947704 Make sure that your session does not hold more locks than necessary
7695- when calling <function>pg_sleep</function>. Otherwise other sessions
7696- might have to wait for your sleeping process, slowing down the entire
7697- system.
7705+ when calling <function>pg_sleep</function> or its variants. Otherwise
7706+ other sessions might have to wait for your sleeping process, slowing down
7707+ the entire system.
76987708 </para>
76997709 </warning>
77007710 </sect2>
0 commit comments