From: | Phil Florent <philflorent(at)hotmail(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | No parallel plan on an union all subquery |
Date: | 2020-11-18 10:46:47 |
Message-ID: | DB7PR05MB6265FE22F31CCF7AAF56CC6CBAE10@DB7PR05MB6265.eurprd05.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I have a question about parallel plans. Here is my test case :
select version();
version
----------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 13.1 (Ubuntu 13.1-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
create unlogged table drop_me as select generate_series(1,7e7) n1;
SELECT 70000000
explain
select count(*)
from (select
n1
from drop_me
) s;
QUERY PLAN
----------------------------------------------------------------------------------------------
Finalize Aggregate (cost=675319.13..675319.14 rows=1 width=8)
-> Gather (cost=675318.92..675319.13 rows=2 width=8)
Workers Planned: 2
-> Partial Aggregate (cost=674318.92..674318.93 rows=1 width=8)
-> Parallel Seq Scan on drop_me (cost=0.00..601402.13 rows=29166713 width=0)
JIT:
Functions: 4
Options: Inlining true, Optimization true, Expressions true, Deforming true
Parallel plan, OK, 1s
explain
select count(*)
from (select
n1
from drop_me
union all
select
n1
from drop_me) ua;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------
Finalize Aggregate (cost=1640315.00..1640315.01 rows=1 width=8)
-> Gather (cost=1640314.96..1640314.99 rows=2 width=8)
Workers Planned: 2
-> Partial Aggregate (cost=1640304.96..1640304.97 rows=1 width=8)
-> Parallel Append (cost=0.00..1494471.40 rows=58333426 width=0)
-> Parallel Seq Scan on drop_me (cost=0.00..601402.13 rows=29166713 width=0)
-> Parallel Seq Scan on drop_me drop_me_1 (cost=0.00..601402.13 rows=29166713 width=0)
JIT:
Functions: 6
Options: Inlining true, Optimization true, Expressions true, Deforming true
Parallel plan, 2s2
explain
select count(*)
from (select
n1
from drop_me
union all
values(1)) ua;
QUERY PLAN
--------------------------------------------------------------------------------
Aggregate (cost=2934739.24..2934739.25 rows=1 width=8)
-> Append (cost=0.00..2059737.83 rows=70000113 width=32)
-> Seq Scan on drop_me (cost=0.00..1009736.12 rows=70000112 width=6)
-> Subquery Scan on "*SELECT* 2" (cost=0.00..0.02 rows=1 width=32)
-> Result (cost=0.00..0.01 rows=1 width=4)
JIT:
Functions: 4
Options: Inlining true, Optimization true, Expressions true, Deforming true
No parallel plan, 2s6
I read the documentation but I don't get the reason of the "noparallel" seq scan of drop_me in the last case ?
Best regards,
Phil
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2020-11-18 11:58:45 | Re: pg_upgrade from 12 to 13 failes with plpython2 |
Previous Message | Snjezana Frketic | 2020-11-18 10:29:44 | How to select values in a JSON type of column? |