【问题标题】:Need parallel append on foreign tables in PostgreSQL需要在 PostgreSQL 中的外部表上并行追加
【发布时间】:2018-09-25 15:27:56
【问题描述】:

我们基于 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 on foreign tables in PostgreSQL 11

【问题讨论】:

    标签: postgresql postgres-fdw postgresql-11


    【解决方案1】:

    为了能够使用Parallel Append,所有孩子都需要安全地在并行工作者中运行。 postgres_fdw 还不能保证安全性(即使从 PostgreSQL 11 开始),因此无法并行扫描由 postgres_fdw 管理的任何子表。

    【讨论】:

    • 我能够对我的 FDW 执行并行附加。除其他事项外,我必须序列化需要在工作人员之间共享的状态结构。很快我会在这里发布答案,更好地解释我是如何做到的。就我而言,我可以确保远程表中的所有扫描都可以并行完成。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-29
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2021-02-06
    • 2016-12-06
    相关资源
    最近更新 更多