Search code examples
databasepostgresqldelaywaitsleep

Delay or Wait-For Statement


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.


Solution

  • Does pgsql have a waitfor statement like t-sql.

    Yes, pg_sleep:

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