postgresql - 需要在 PostgreSQL 中的外部表上进行并行追加

标签 postgresql postgres-fdw postgresql-11

我们开发了一个基于 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

最佳答案

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

关于postgresql - 需要在 PostgreSQL 中的外部表上进行并行追加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52501783/

相关文章:

python - 如何以给定的数字启动 SQLAlchemy primary_key?

Postgresql - 范围约束 - 两个表

Django 模型引用 postgres 外部表 (clickhouse_fdw)

python - 将数据从 redis 哈希转储到 postgresql 表的更快方法

ruby-on-rails - Travis CI 未连接到 PostgreSQL 11.2

性能类型 varchar(1) 或 smallint 来存储状态 Postgres

sql - 无法在 PostgreSQL 中插入具有主键约束的字段

sql - 如何使用 postgres dblink 更新另一个数据库中的表?

PostgreSQL服务器连接错误: could not connect to server

postgresql - PL/pgSQL 无限循环