问题描述
我需要使两个会话(两个文件)同时(同时)运行。有没有办法使用pg_sleep或其他诸如 delayExecutionUntil(x_time)之类的功能来做到这一点?
I need to make two sessions (two files) run concurrently (at the same time). Is there a way to do this using pg_sleep or some other function like "delayExecutionUntil(x_time)"?
推荐答案
要进行两次交易(几乎)在同一时间,您可以安排两次或多次调用中。
To get two transactions at the (almost) exact same time, you could schedule two or more invocations of psql at the same time in a Linux shell with the at
command.
就像:
at '08:00 01.12.2012' -f script.sql
(所需的时间戳格式可能取决于您的系统区域设置。)
其中, script.sql
包含以下内容:
(The required timestamp format may depend on your system locale.)
Where script.sql
contains something like:
psql mydb -p 5432 -c "INSERT INTO tbl (col) VALUES ('foo');
只有更多的行会引起您所追求的碰撞..
Just with a lot more rows to provoke the collisions you are after ..
这篇关于PostgreSQL-使两个事务同时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!