Delay or Wait-For Statement

独自空忆成欢 提交于 2019-12-04 22:35:10

Does pgsql have a waitfor statement like t-sql.

Yes, pg_sleep:

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

(1 row)

You could call the pg_sleep function with the PERFORM statement since we don't care about returning values:

PERFORM pg_sleep(10);
Jamie Love

Not to my knowledge.

You could do something in the shell, piping your SQL through a simple script and then into PostgreSQL. E.g. with Perl:

cat regionupdates.sql | perl -e '$i = 1; while(<STDIN>) { $i++; print $_; if ($i % 50 == 0) { sleep 10; } }' | psql -d MYDB -L output.txt

BTW: I see you asked a very similar question before. It would be nice if you could accept the answers you found solved your problem:

Begin...commit every 50 rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!