pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yang, Rong <yangr.fnst@cn.fujitsu.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: how to get top plan of GatherMerge in OSS10
Date: Fri, 4 Sep 2020 08:20:56 +0000
Message-ID: <1599207928905.13720@cn.fujitsu.com> (raw)

Hello~

When I look at the plan for a query in OSS11 and OSS10, the plan tree structure is different.
OSS10.13:
postgres=# explain (costs off) select C,((select c_int  from table1 where C<=2)except all(select c_int  from table1 where C=2)) from table1 where C < 100 order by C;
                              QUERY PLAN
----------------------------------------------------------------------
Sort
   Sort Key: table1.c
   InitPlan 1 (returns $2)
     ->  HashSetOp Except All
           ->  Append
                 ->  Subquery Scan on "*SELECT* 1"
                       ->  Gather
                             Workers Planned: 2
                             ->  Parallel Seq Scan on table1 table1_1
                                   Filter: (c <= 2)
                 ->  Subquery Scan on "*SELECT* 2"
                       ->  Gather
                            Workers Planned: 2
                             ->  Parallel Seq Scan on table1 table1_2
                                   Filter: (c = 2)
   ->  Gather
         Workers Planned: 2
         ->  Parallel Seq Scan on table1
               Filter: (c < 100)
(19 rows)

OSS11.8:
postgres=# explain (costs off) select C,((select c_int  from table1 where C<=2)except all(select c_int  from table1 where C=2)) from table1 where C < 100 order by C;
                              QUERY PLAN
----------------------------------------------------------------------
Gather Merge
   Workers Planned: 2
   Params Evaluated: $2
   InitPlan 1 (returns $2)
     ->  HashSetOp Except All
           ->  Append
                 ->  Subquery Scan on "*SELECT* 1"
                       ->  Gather
                             Workers Planned: 2
                             ->  Parallel Seq Scan on table1 table1_1
                                   Filter: (c <= 2)
                 ->  Subquery Scan on "*SELECT* 2"
                       ->  Gather
                             Workers Planned: 2
                             ->  Parallel Seq Scan on table1 table1_2
                                   Filter: (c = 2)
   ->  Sort
         Sort Key: table1.c
         ->  Parallel Seq Scan on table1
               Filter: (c < 100)
(20 rows)

Data in a table and Database configuration are the same,as follows:
create table table1(C int, c_int int, c_varchar varchar(1024),c_bigint bigint, c_varchar2 varchar(1024),c_time timestamp);
insert into table1 values(1,10,'10000tt1111t',123456789,'012-3456-7890','2018-05-06 10:00:00');
insert into table1 values(2,20,'20000tt2t222t',223456789,'023-3486-2342','2019-05-06 10:00:00');
insert into table1 values(3,30,'30000tt3t333tt',323456789,'021-9823-8821','2020-05-06 10:00:00');
insert into table1 values(4,20,'20000tt2t222t',223456789,'023-3486-2342','2019-05-06 10:00:00');
set enable_sort=off;
set force_parallel_mode to on;
set parallel_setup_cost to 0.1;
set min_parallel_table_scan_size to 0;
set min_parallel_index_scan_size to 0;
insert into table1 select generate_series(10,1000000),generate_series(100,100000),'aaa',777777777,'012-3456-7890','2018-05-06 10:00:00';

question:
in OSS 10, how  to make the top plan of the plan tree to GatherMerge with ‘except all’ in sql?





view thread (2+ messages)  latest in thread

Message-ID: <1599207928905.13720@cn.fujitsu.com>
Permalink:  ../1599207928905.13720@cn.fujitsu.com/
Also on:    postgresql.org/message-id/1599207928905.13720@cn.fujitsu.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: yangr.fnst@cn.fujitsu.com
  Subject: Re: how to get top plan of GatherMerge in OSS10
  In-Reply-To: <1599207928905.13720@cn.fujitsu.com>
  References: <1599207928905.13720@cn.fujitsu.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox