Delay or Wait-For Statement

sharadov picture sharadov · Aug 26, 2009 · Viewed 28k times · Source

I have a 500,000 line SQL script:

update users set region_id = 9814746 where id = 101 and region_id is null;
update users set region_id = 9814731 where id = 102 and region_id is null;
update users set region_id = 3470676 where id = 103 and region_id is null;

I want to INSERT a delay of 10 seconds every 50 lines. Does pgsql have a waitfor statement like t-sql.

Thanks.

Answer

pilcrow picture pilcrow · Aug 26, 2009

Does pgsql have a waitfor statement like t-sql.

Yes, pg_sleep:

pg=> SELECT pg_sleep(10);
 pg_sleep 
----------

(1 row)