cloudberry icon indicating copy to clipboard operation
cloudberry copied to clipboard

Enable partition selector in single node mode.

Open my-ship-it opened this issue 2 years ago • 1 comments

When we create Cloudberry cluster in single node mode, partition selector is disabled. We want to enable it so we could get following plan:

create table lprt_a (a int not null);
-- Insert some values we won't find in ab
insert into lprt_a select 0 from generate_series(1,100);
-- and insert some values that we should find.
insert into lprt_a values(1),(1);
analyze lprt_a;
create index ab_a2_b1_a_idx on ab_a2_b1 (a);
create index ab_a2_b2_a_idx on ab_a2_b2 (a);
create index ab_a2_b3_a_idx on ab_a2_b3 (a);
create index ab_a1_b1_a_idx on ab_a1_b1 (a);
create index ab_a1_b2_a_idx on ab_a1_b2 (a);
create index ab_a1_b3_a_idx on ab_a1_b3 (a);
create index ab_a3_b1_a_idx on ab_a3_b1 (a);
create index ab_a3_b2_a_idx on ab_a3_b2 (a);
create index ab_a3_b3_a_idx on ab_a3_b3 (a);
set enable_hashjoin = 0;
set enable_mergejoin = 0;
set enable_memoize = 0;
select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(0, 0, 1)');
                                    explain_parallel_append
------------------------------------------------------------------------------------------------
 Finalize Aggregate (actual rows=N loops=N)
   ->  Gather Motion 1:1  (slice1; segments: 1) (actual rows=N loops=N)
         ->  Partial Aggregate (actual rows=N loops=N)
               ->  Merge Join (never executed)
                     Merge Cond: (ab.a = a.a)
                     ->  Sort (never executed)
                           Sort Key: ab.a
                           Sort Method:  quicksort  Memory: 50kB
                           ->  Append (never executed)
                                 Partition Selectors: $0
                                 ->  Bitmap Heap Scan on ab_a1_b1 ab_1 (never executed)
                                       Recheck Cond: (a = ANY ('{0,0,1}'::integer[]))
                                       ->  Bitmap Index Scan on ab_a1_b1_a_idx (never executed)
                                             Index Cond: (a = ANY ('{0,0,1}'::integer[]))
                                 ->  Bitmap Heap Scan on ab_a1_b2 ab_2 (never executed)
                                       Recheck Cond: (a = ANY ('{0,0,1}'::integer[]))
                                       ->  Bitmap Index Scan on ab_a1_b2_a_idx (never executed)
                                             Index Cond: (a = ANY ('{0,0,1}'::integer[]))
                                 ->  Bitmap Heap Scan on ab_a1_b3 ab_3 (never executed)
                                       Recheck Cond: (a = ANY ('{0,0,1}'::integer[]))
                                       ->  Bitmap Index Scan on ab_a1_b3_a_idx (never executed)
                                             Index Cond: (a = ANY ('{0,0,1}'::integer[]))
                     ->  Sort (actual rows=N loops=N)
                           Sort Key: a.a
                           Sort Method:  quicksort  Memory: 60kB
                           ->  Partition Selector (selector id: $0) (actual rows=N loops=N)
                                 ->  Seq Scan on lprt_a a (actual rows=N loops=N)
                                       Filter: (a = ANY ('{0,0,1}'::integer[]))
 Optimizer: Postgres query optimizer

my-ship-it avatar Jul 17 '23 05:07 my-ship-it

Hey, @my-ship-it welcome!🎊 Thanks for taking the time to point this out.🙌

github-actions[bot] avatar Jul 17 '23 05:07 github-actions[bot]