Skip to content

Commit

Permalink
Fix the icw tests which generated by dynamic (bitmap/index/table) scan
Browse files Browse the repository at this point in the history
The reason for the current test failure is not only that the scan
of the partition table has been changed to a dynamic scan, but
also that we have disabled the index scan in nest loop in ORCA.
  • Loading branch information
jiaqizho authored and my-ship-it committed Dec 24, 2024
1 parent 5612f4b commit 43ca55d
Show file tree
Hide file tree
Showing 12 changed files with 712 additions and 503 deletions.
7 changes: 3 additions & 4 deletions src/test/regress/expected/aggregates_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -1431,11 +1431,10 @@ explain (costs off) select * from p_t1 group by a,b,c,d;
QUERY PLAN
------------------------------------------
Gather Motion 3:1 (slice1; segments: 3)
-> Append
-> Seq Scan on p_t1_1
-> Seq Scan on p_t1_2
-> Dynamic Seq Scan on p_t1
Number of partitions to scan: 2
Optimizer: Pivotal Optimizer (GPORCA)
(5 rows)
(4 rows)

drop table t1 cascade;
NOTICE: drop cascades to table t1c
Expand Down
122 changes: 78 additions & 44 deletions src/test/regress/expected/bfv_index_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -127,55 +127,89 @@ explain SELECT count(*)
FROM bfv_tab2_facttable1 ft, bfv_tab2_dimdate dt, bfv_tab2_dimtabl1 dt1
WHERE ft.wk_id = dt.wk_id
AND ft.id = dt1.id;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=0.00..1250.34 rows=1 width=8)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..1250.34 rows=7 width=1)
-> Hash Join (cost=0.00..1250.34 rows=3 width=1)
Hash Cond: (bfv_tab2_dimdate.wk_id = bfv_tab2_facttable1.wk_id)
-> Seq Scan on bfv_tab2_dimdate (cost=0.00..431.00 rows=4 width=2)
-> Hash (cost=819.34..819.34 rows=3 width=2)
-> Redistribute Motion 3:3 (slice2; segments: 3) (cost=0.00..819.34 rows=3 width=2)
Hash Key: bfv_tab2_facttable1.wk_id
-> Nested Loop (cost=0.00..819.34 rows=3 width=2)
Join Filter: true
-> Broadcast Motion 3:3 (slice3; segments: 3) (cost=0.00..431.00 rows=7 width=4)
-> Seq Scan on bfv_tab2_dimtabl1 (cost=0.00..431.00 rows=3 width=4)
-> Dynamic Bitmap Heap Scan on bfv_tab2_facttable1 (cost=0.00..388.34 rows=1 width=2)
Number of partitions to scan: 21
Recheck Cond: (id = bfv_tab2_dimtabl1.id)
Filter: (id = bfv_tab2_dimtabl1.id)
-> Dynamic Bitmap Index Scan on idx_bfv_tab2_facttable1 (cost=0.00..0.00 rows=0 width=0)
Index Cond: (id = bfv_tab2_dimtabl1.id)
Optimizer: Pivotal Optimizer (GPORCA)
(19 rows)
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=23.80..23.81 rows=1 width=8)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=2.28..23.79 rows=3 width=0)
-> Hash Join (cost=2.28..23.74 rows=1 width=0)
Hash Cond: (ft.wk_id = dt.wk_id)
-> Redistribute Motion 3:3 (slice2; segments: 3) (cost=1.20..22.65 rows=2 width=2)
Hash Key: ft.wk_id
-> Hash Join (cost=1.20..22.60 rows=2 width=2)
Hash Cond: (ft.id = dt1.id)
-> Append (cost=0.00..21.32 rows=21 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_2 ft_1 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_3 ft_2 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_4 ft_3 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_5 ft_4 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_6 ft_5 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_7 ft_6 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_8 ft_7 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_9 ft_8 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_10 ft_9 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_11 ft_10 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_12 ft_11 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_13 ft_12 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_14 ft_13 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_15 ft_14 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_16 ft_15 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_17 ft_16 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_18 ft_17 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_19 ft_18 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_20 ft_19 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_21 ft_20 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_dflt ft_21 (cost=0.00..1.01 rows=1 width=6)
-> Hash (cost=1.12..1.12 rows=7 width=4)
-> Broadcast Motion 3:3 (slice3; segments: 3) (cost=0.00..1.12 rows=7 width=4)
-> Seq Scan on bfv_tab2_dimtabl1 dt1 (cost=0.00..1.02 rows=2 width=4)
-> Hash (cost=1.03..1.03 rows=3 width=2)
-> Seq Scan on bfv_tab2_dimdate dt (cost=0.00..1.03 rows=3 width=2)
Optimizer: Postgres query optimizer
(36 rows)

explain SELECT count(*)
FROM bfv_tab2_facttable1 ft, bfv_tab2_dimdate dt, bfv_tab2_dimtabl1 dt1
WHERE ft.wk_id = dt.wk_id
AND ft.id = dt1.id;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=0.00..1250.34 rows=1 width=8)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..1250.34 rows=7 width=1)
-> Hash Join (cost=0.00..1250.34 rows=3 width=1)
Hash Cond: (bfv_tab2_dimdate.wk_id = bfv_tab2_facttable1.wk_id)
-> Seq Scan on bfv_tab2_dimdate (cost=0.00..431.00 rows=4 width=2)
-> Hash (cost=819.34..819.34 rows=3 width=2)
-> Redistribute Motion 3:3 (slice2; segments: 3) (cost=0.00..819.34 rows=3 width=2)
Hash Key: bfv_tab2_facttable1.wk_id
-> Nested Loop (cost=0.00..819.34 rows=3 width=2)
Join Filter: true
-> Broadcast Motion 3:3 (slice3; segments: 3) (cost=0.00..431.00 rows=7 width=4)
-> Seq Scan on bfv_tab2_dimtabl1 (cost=0.00..431.00 rows=3 width=4)
-> Dynamic Bitmap Heap Scan on bfv_tab2_facttable1 (cost=0.00..388.34 rows=1 width=2)
Number of partitions to scan: 21
Recheck Cond: (id = bfv_tab2_dimtabl1.id)
Filter: (id = bfv_tab2_dimtabl1.id)
-> Dynamic Bitmap Index Scan on idx_bfv_tab2_facttable1 (cost=0.00..0.00 rows=0 width=0)
Index Cond: (id = bfv_tab2_dimtabl1.id)
Optimizer: Pivotal Optimizer (GPORCA)
(19 rows)
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=23.80..23.81 rows=1 width=8)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=2.28..23.79 rows=3 width=0)
-> Hash Join (cost=2.28..23.74 rows=1 width=0)
Hash Cond: (ft.wk_id = dt.wk_id)
-> Redistribute Motion 3:3 (slice2; segments: 3) (cost=1.20..22.65 rows=2 width=2)
Hash Key: ft.wk_id
-> Hash Join (cost=1.20..22.60 rows=2 width=2)
Hash Cond: (ft.id = dt1.id)
-> Append (cost=0.00..21.32 rows=21 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_2 ft_1 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_3 ft_2 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_4 ft_3 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_5 ft_4 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_6 ft_5 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_7 ft_6 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_8 ft_7 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_9 ft_8 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_10 ft_9 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_11 ft_10 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_12 ft_11 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_13 ft_12 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_14 ft_13 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_15 ft_14 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_16 ft_15 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_17 ft_16 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_18 ft_17 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_19 ft_18 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_20 ft_19 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_21 ft_20 (cost=0.00..1.01 rows=1 width=6)
-> Seq Scan on bfv_tab2_facttable1_1_prt_dflt ft_21 (cost=0.00..1.01 rows=1 width=6)
-> Hash (cost=1.12..1.12 rows=7 width=4)
-> Broadcast Motion 3:3 (slice3; segments: 3) (cost=0.00..1.12 rows=7 width=4)
-> Seq Scan on bfv_tab2_dimtabl1 dt1 (cost=0.00..1.02 rows=2 width=4)
-> Hash (cost=1.03..1.03 rows=3 width=2)
-> Seq Scan on bfv_tab2_dimdate dt (cost=0.00..1.03 rows=3 width=2)
Optimizer: Postgres query optimizer
(36 rows)

-- start_ignore
create language plpython3u;
Expand Down
1 change: 1 addition & 0 deletions src/test/regress/expected/bfv_partition_plans.out
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sur
insert into mpp23195_t1 values (generate_series(1,19));
insert into mpp23195_t2 values (1);
-- TEST
-- Operator Fallback: InnerIndexNestLoopJoin may have wrong plan not supported
select find_operator('select * from mpp23195_t1,mpp23195_t2 where mpp23195_t1.i < mpp23195_t2.i;', 'Dynamic Index Scan');
find_operator
---------------
Expand Down
3 changes: 2 additions & 1 deletion src/test/regress/expected/bfv_partition_plans_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sur
insert into mpp23195_t1 values (generate_series(1,19));
insert into mpp23195_t2 values (1);
-- TEST
-- Operator Fallback: InnerIndexNestLoopJoin may have wrong plan not supported
select find_operator('select * from mpp23195_t1,mpp23195_t2 where mpp23195_t1.i < mpp23195_t2.i;', 'Dynamic Index Scan');
find_operator
---------------
['true']
['false']
(1 row)

select * from mpp23195_t1,mpp23195_t2 where mpp23195_t1.i < mpp23195_t2.i;
Expand Down
Loading

0 comments on commit 43ca55d

Please sign in to comment.