使用 bash 和 psql 并行化 postgres 查询?

使用 bash 和 psql 并行化 postgres 查询?

我正在尝试使用 bash + psql 并行运行一系列对单独表进行操作的 postgres 函数/存储过程,如下所示:

psql -d samples_20160612_0616 -c "select insert_function('2016-6-14 20:00'::timestamp, '2016-6-14 21:00'::timestamp)" &
psql -d samples_20160612_0616 -c "select insert_function('2016-6-15 19:00'::timestamp, '2016-6-15 20:00'::timestamp)" &
psql -d samples_20160612_0616 -c "select insert_function('2016-6-15 20:00'::timestamp, '2016-6-15 21:00'::timestamp)" &
psql -d samples_20160612_0616 -c "select insert_function('2016-6-16 19:00'::timestamp, '2016-6-16 20:00'::timestamp)" &
psql -d samples_20160612_0616 -c "select insert_function('2016-6-16 20:00'::timestamp, '2016-6-16 21:00'::timestamp)"

由于某种原因,这些语句似乎不是按预期并行运行,而是串行运行。

我在这里做错了什么?这不应该并行运行吗?

相关内容