是否可以在 PostgreSQL 11 中的外部表上实现并行追加(就像在本地表上一样)?
本地表:
# select version();
version
---------------------------------------------------------------------------------------------------
PostgreSQL 11beta3 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10+deb8u1) 4.9.2, 64-bit
(1 row)
# create table local_table_1 as select generate_series(1, 1000000);
SELECT 1000000
# create table local_table_2 as select generate_series(1, 1000000);
SELECT 1000000
# create table local_table (like local_table_1);
CREATE TABLE
# alter table local_table_1 inherit local_table;
ALTER TABLE
# alter table local_table_2 inherit local_table;
ALTER TABLE
# explain analyze select count(*) from local_table;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------
Finalize Aggregate (cost=25369.62..25369.63 rows=1 width=8) (actual time=209.538..209.538 rows=1 loops=1)
-> Gather (cost=25369.41..25369.62 rows=2 width=8) (actual time=209.446..211.924 rows=3 loops=1)
Workers Planned: 2
Workers Launched: 2
-> Partial Aggregate (cost=24369.41..24369.42 rows=1 width=8) (actual time=191.494..191.494 rows=1 loops=3)
-> Parallel Append (cost=0.00..22152.35 rows=886824 width=0) (actual time=0.121..144.302 rows=666667 loops=3)
-> Parallel Seq Scan on local_table_2 (cost=0.00..9126.56 rows=470156 width=0) (actual time=0.064..47.920 rows=333333 loops=3)
-> Parallel Seq Scan on local_table_1 (cost=0.00..8591.67 rows=416667 width=0) (actual time=0.130..67.098 rows=500000 loops=2)
-> Parallel Seq Scan on local_table (cost=0.00..0.00 rows=1 width=0) (actual time=0.002..0.002 rows=0 loops=1)
Planning Time: 0.516 ms
Execution Time: 212.026 ms
(11 rows)
国外表:
# explain analyze select count(*) from foreign_table;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=4308.62..4308.63 rows=1 width=8) (actual time=93729.176..93729.176 rows=1 loops=1)
-> Append (cost=0.00..4044.11 rows=105804 width=0) (actual time=6868.904..93430.855 rows=5520175 loops=1)
-> Seq Scan on foreign_table (cost=0.00..0.00 rows=1 width=0) (actual time=0.013..0.013 rows=0 loops=1)
-> Foreign Scan on foreign_table foreign_table_1 (cost=1.00..113.39 rows=3413 width=0) (actual time=6868.889..6879.804 rows=195460 loops=1)
-> 29 more foreign tables
-> Foreign Scan on foreign_table foreign_table_31 (cost=1.00..113.39 rows=3413 width=0) (actual time=3139.317..3150.340 rows=199581 loops=1)
Planning Time: 3.205 ms
Execution Time: 110707.099 ms
(36 rows)
是否有任何参数可以提示 postgres 在外部表上使用并行追加?