What do they do?
pg_sleep() itself is used to stop the execution (as example of a file with SQL commands) for the specified amount of seconds. The number of seconds can be specified as fraction.
Works quite well, the execution time is almost exactly
That is useful for short delays. But what when the waiting time is supposed to be longer? Or the execution shall wait until a specific time? Using
pg_sleep() only, one has to calculate the number of seconds.
pg_sleep_for() uses an interval, and the time can be specified in a more human readable form.
And then there is
pg_sleep_until(), which uses a timestamp and waits until that time.
In this example I just picked the next full minute at the time when I was writing this blog post.
All in all very useful.
But Vik has to fix one last remaining bug, which he quoted here: