我们开发了一个基于 postgres_fdw 的 fdw,它在保持数据压缩的大存储库(大数据)中实现搜索。我们尝试使用 postgres 分区表的概念,这样我们就可以同时在多个分区上进行并行搜索。对于外部数据包装器,我们需要“并行追加”。
有人知道它是否会在 Postgres 11 中得到解决吗?
如果我的查询导致在本地分区搜索,postgres 会使用并行性,但如果它导致外部扫描,它不会。
本地分区:
explain select * from precio where fecha >= '2017-01-20' and fecha <= '2017-01-21' and plusalesprice < 1
Gather (cost=1000.00..969527.35 rows=81568 width=60)
Workers Planned: 2
-> Parallel Append (cost=0.00..960370.55 rows=33986 width=60)
-> Parallel Seq Scan on precio_20170121 (cost=0.00..589086.00 rows=19293 width=60)
Filter: ((fecha >= '2017-01-20'::date) AND (fecha <= '2017-01-21'::date) AND (plusalesprice < '1'::numeric))
-> Parallel Seq Scan on precio_20170120 (cost=0.00..371114.62 rows=14693 width=60)
Filter: ((fecha >= '2017-01-20'::date) AND (fecha <= '2017-01-21'::date) AND (plusalesprice < '1'::numeric))
外部分区:
explain select * from precio where fecha >= '2017-01-01' and fecha <= '2017-01-02' and plusalesprice < 1
Append (cost=200.00..2650400.00 rows=20000000 width=60)
-> Foreign Scan on precio_xdr20170101 (cost=200.00..1275200.00 rows=10000000 width=60)
Filter: ((fecha >= '2017-01-01'::date) AND (fecha <= '2017-01-02'::date) AND (plusalesprice < '1'::numeric))
-> Foreign Scan on precio_xdr20170102 (cost=200.00..1275200.00 rows=10000000 width=60)
Filter: ((fecha >= '2017-01-01'::date) AND (fecha <= '2017-01-02'::date) AND (plusalesprice < '1'::numeric))
最佳答案
为了能够使用Parallel Append
,所有子级都需要安全地在并行 worker 中运行。 postgres_fdw
还不能保证安全性(即使从 PostgreSQL 11 开始也是如此),因此无法并行扫描由 postgres_fdw
管理的任何子表。
关于postgresql - 需要在 PostgreSQL 中的外部表上进行并行追加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52501783/