Skip to content

Commit e0e62f4

Browse files
author
kongfanshen
committed
test: Right Semi Join regression tests and answer-file updates
Add src/test/regress/sql/rightsemijoin.sql (registered in greenplum_schedule) with planner and GPORCA answer files asserting that optimizer_enable_right_semi_join flips the plan between Hash Right Semi/Anti Join and the regular Hash Semi/Anti Join, with identical results. Regenerate the answer files affected by the new Hash Right Semi/Anti Join plan shapes across the core, PAX (contrib/pax_storage) and singlenode regress suites (both planner .out and GPORCA _optimizer.out), including new partition_append_optimizer.out / partition_join_optimizer.out / rpt_joins_optimizer.out where GPORCA now diverges from the planner. Results are unchanged; only EXPLAIN plan shapes differ.
1 parent bb830db commit e0e62f4

63 files changed

Lines changed: 41116 additions & 21838 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

contrib/pax_storage/src/test/regress/expected/DML_over_joins_optimizer.out

Lines changed: 266 additions & 155 deletions
Large diffs are not rendered by default.

contrib/pax_storage/src/test/regress/expected/bfv_partition_plans.out

Lines changed: 66 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SET optimizer_trace_fallback=on;
2424
--
2525
-- start_ignore
2626
create language plpython3u;
27-
ERROR: language "plpython3u" already exists
27+
ERROR: extension "plpython3u" already exists
2828
-- end_ignore
2929
create or replace function count_operator(query text, operator text) returns int as
3030
$$
@@ -98,10 +98,10 @@ insert into mpp7980 values('2009-03-03','xyz','zyz','4',1,3,'1');
9898
select cust_type, subscription_status,count(distinct subscription_id),sum(voice_call_min),sum(minute_per_call) from mpp7980 where month_id ='2009-04-01' group by rollup(1,2);
9999
cust_type | subscription_status | count | sum | sum
100100
-----------+---------------------+-------+------+------
101-
| | 1 | 3.00 | 2.00
102-
zyz | | 1 | 3.00 | 2.00
103101
zyz | 1 | 1 | 1.00 | 1.00
104102
zyz | 2 | 1 | 2.00 | 1.00
103+
zyz | | 1 | 3.00 | 2.00
104+
| | 1 | 3.00 | 2.00
105105
(4 rows)
106106

107107
-- CLEANUP
@@ -113,6 +113,7 @@ drop table mpp7980;
113113
-- SETUP
114114
-- start_ignore
115115
set optimizer_enable_bitmapscan=on;
116+
set optimizer_enable_dynamicbitmapscan=on;
116117
set optimizer_enable_indexjoin=on;
117118
drop table if exists mpp23195_t1;
118119
NOTICE: table "mpp23195_t1" does not exist, skipping
@@ -157,6 +158,7 @@ select * from mpp23195_t1,mpp23195_t2 where mpp23195_t1.i < mpp23195_t2.i;
157158
drop table if exists mpp23195_t1;
158159
drop table if exists mpp23195_t2;
159160
set optimizer_enable_bitmapscan=off;
161+
set optimizer_enable_dynamicbitmapscan=off;
160162
set optimizer_enable_indexjoin=off;
161163
-- end_ignore
162164
--
@@ -795,6 +797,7 @@ reset optimizer_segments;
795797
-- SETUP
796798
-- start_ignore
797799
DROP TABLE IF EXISTS bar;
800+
NOTICE: table "bar" does not exist, skipping
798801
-- end_ignore
799802
CREATE TABLE bar (b int, c int)
800803
PARTITION BY RANGE (b)
@@ -809,26 +812,26 @@ ANALYZE bar;
809812
SELECT b FROM bar GROUP BY b;
810813
b
811814
----
812-
7
813-
4
815+
8
814816
19
815-
3
816-
5
817+
7
817818
18
818-
6
819-
11
820-
9
821-
8
822-
12
823-
10
824-
17
825-
1
826-
0
819+
4
827820
2
828821
16
822+
3
829823
15
830-
14
824+
0
825+
1
826+
12
827+
17
828+
11
831829
13
830+
10
831+
9
832+
5
833+
6
834+
14
832835
(20 rows)
833836

834837
EXPLAIN SELECT b FROM bar GROUP BY b;
@@ -845,6 +848,7 @@ EXPLAIN SELECT b FROM bar GROUP BY b;
845848

846849
-- CLEANUP
847850
DROP TABLE IF EXISTS foo;
851+
NOTICE: table "foo" does not exist, skipping
848852
DROP TABLE IF EXISTS bar;
849853
-- Test EXPLAIN ANALYZE on a partitioned table. There used to be a bug, where
850854
-- you got an internal error with this, because the EXPLAIN ANALYZE sends the
@@ -867,26 +871,26 @@ HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sur
867871
explain analyze select a.* from mpp8031 a, mpp8031 b where a.oid = b.oid;
868872
QUERY PLAN
869873
------------------------------------------------------------------------------------------------------------------------------------------
870-
Gather Motion 3:1 (slice1; segments: 3) (cost=2743.00..2475974.00 rows=80883360 width=16) (actual time=0.707..0.709 rows=0 loops=1)
871-
-> Hash Join (cost=2743.00..1397529.20 rows=26961120 width=16) (actual time=0.024..0.028 rows=0 loops=1)
874+
Gather Motion 3:1 (slice1; segments: 3) (cost=2743.00..2475974.00 rows=80883360 width=16) (actual time=5.088..5.091 rows=0 loops=1)
875+
-> Hash Join (cost=2743.00..1397529.20 rows=26961120 width=16) (actual time=0.223..0.225 rows=0 loops=1)
872876
Hash Cond: (a.oid = b.oid)
873-
-> Append (cost=0.00..1558.00 rows=94800 width=16) (actual time=0.021..0.023 rows=0 loops=1)
874-
-> Seq Scan on mpp8031_1_prt_foo_1 a_1 (cost=0.00..271.00 rows=23700 width=16) (actual time=0.010..0.010 rows=0 loops=1)
875-
-> Seq Scan on mpp8031_1_prt_2 a_2 (cost=0.00..271.00 rows=23700 width=16) (actual time=0.003..0.004 rows=0 loops=1)
876-
-> Seq Scan on mpp8031_1_prt_3 a_3 (cost=0.00..271.00 rows=23700 width=16) (actual time=0.003..0.003 rows=0 loops=1)
877-
-> Seq Scan on mpp8031_1_prt_4 a_4 (cost=0.00..271.00 rows=23700 width=16) (actual time=0.003..0.003 rows=0 loops=1)
877+
-> Append (cost=0.00..1558.00 rows=94800 width=16) (actual time=0.221..0.223 rows=0 loops=1)
878+
-> Seq Scan on mpp8031_1_prt_foo_1 a_1 (cost=0.00..271.00 rows=23700 width=16) (actual time=0.102..0.102 rows=0 loops=1)
879+
-> Seq Scan on mpp8031_1_prt_2 a_2 (cost=0.00..271.00 rows=23700 width=16) (actual time=0.031..0.031 rows=0 loops=1)
880+
-> Seq Scan on mpp8031_1_prt_3 a_3 (cost=0.00..271.00 rows=23700 width=16) (actual time=0.037..0.037 rows=0 loops=1)
881+
-> Seq Scan on mpp8031_1_prt_4 a_4 (cost=0.00..271.00 rows=23700 width=16) (actual time=0.051..0.051 rows=0 loops=1)
878882
-> Hash (cost=1558.00..1558.00 rows=94800 width=4) (never executed)
879883
-> Append (cost=0.00..1558.00 rows=94800 width=4) (never executed)
880884
-> Seq Scan on mpp8031_1_prt_foo_1 b_1 (cost=0.00..271.00 rows=23700 width=4) (never executed)
881885
-> Seq Scan on mpp8031_1_prt_2 b_2 (cost=0.00..271.00 rows=23700 width=4) (never executed)
882886
-> Seq Scan on mpp8031_1_prt_3 b_3 (cost=0.00..271.00 rows=23700 width=4) (never executed)
883887
-> Seq Scan on mpp8031_1_prt_4 b_4 (cost=0.00..271.00 rows=23700 width=4) (never executed)
884-
Planning Time: 2.080 ms
885-
(slice0) Executor memory: 122K bytes.
886-
(slice1) Executor memory: 121K bytes avg x 3x(0) workers, 121K bytes max (seg0).
888+
Planning Time: 0.374 ms
889+
(slice0) Executor memory: 52K bytes.
890+
(slice1) Executor memory: 149K bytes avg x 3x(0) workers, 149K bytes max (seg0).
887891
Memory used: 128000kB
888892
Optimizer: Postgres query optimizer
889-
Execution Time: 1.279 ms
893+
Execution Time: 5.529 ms
890894
(20 rows)
891895

892896
drop table mpp8031;
@@ -915,6 +919,9 @@ INSERT INTO part_tbl VALUES (2015111000, 479534741, 99999999);
915919
INSERT INTO part_tbl VALUES (2015111000, 479534742, 99999999);
916920
CREATE INDEX part_tbl_idx
917921
ON part_tbl(profile_key);
922+
-- start_ignore
923+
analyze part_tbl;
924+
-- end_ignore
918925
EXPLAIN SELECT * FROM part_tbl WHERE profile_key = 99999999;
919926
QUERY PLAN
920927
---------------------------------------------------------------------------------------------------------------------
@@ -1140,9 +1147,9 @@ explain select * from fact where dd < current_date; --partitions eliminated
11401147
-----------------------------------------------------------------------------
11411148
Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..1.03 rows=1 width=40)
11421149
-> Seq Scan on fact_1_prt_1 fact (cost=0.00..1.01 rows=1 width=40)
1143-
Filter: (dd < '04-28-2022'::date)
1150+
Filter: (dd < '06-21-2026'::date)
11441151
Optimizer: Postgres query optimizer
1145-
(6 rows)
1152+
(4 rows)
11461153

11471154
-- Test partition elimination in prepared statements
11481155
prepare f1(date) as select * from fact where dd < $1;
@@ -1227,39 +1234,37 @@ INSERT INTO delete_from_pt SELECT i, i%6 FROM generate_series(1, 10)i;
12271234
INSERT INTO t VALUES (1);
12281235
ANALYZE delete_from_pt, t;
12291236
EXPLAIN (COSTS OFF, TIMING OFF, SUMMARY OFF, ANALYZE) DELETE FROM delete_from_pt WHERE b IN (SELECT b FROM delete_from_pt, t WHERE t.a=delete_from_pt.b);
1230-
QUERY PLAN
1231-
-----------------------------------------------------------------------------------------------------------------------
1237+
QUERY PLAN
1238+
-----------------------------------------------------------------------------------------------------------
12321239
Delete on delete_from_pt (actual rows=0 loops=1)
12331240
Delete on delete_from_pt_1_prt_1 delete_from_pt_2
12341241
Delete on delete_from_pt_1_prt_2 delete_from_pt_3
12351242
Delete on delete_from_pt_1_prt_3 delete_from_pt_4
1236-
-> Hash Semi Join (actual rows=1 loops=1)
1237-
Hash Cond: (delete_from_pt.b = t.a)
1238-
Extra Text: (seg0) Hash chain length 2.0 avg, 2 max, using 1 of 131072 buckets.
1239-
-> Append (actual rows=3 loops=1)
1240-
Partition Selectors: $1
1241-
-> Seq Scan on delete_from_pt_1_prt_1 delete_from_pt_2 (actual rows=3 loops=1)
1242-
-> Seq Scan on delete_from_pt_1_prt_2 delete_from_pt_3 (never executed)
1243-
-> Seq Scan on delete_from_pt_1_prt_3 delete_from_pt_4 (never executed)
1244-
-> Hash (actual rows=2 loops=1)
1243+
-> Hash Right Semi Join (actual rows=1 loops=1)
1244+
Hash Cond: (t.a = delete_from_pt.b)
1245+
Extra Text: (seg0) Hash chain length 1.2 avg, 2 max, using 4 of 131072 buckets.
1246+
-> Broadcast Motion 3:3 (slice1; segments: 3) (actual rows=2 loops=1)
1247+
-> Hash Join (actual rows=1 loops=1)
1248+
Hash Cond: (delete_from_pt_1.b = t.a)
1249+
Extra Text: (seg0) Hash chain length 1.0 avg, 1 max, using 1 of 262144 buckets.
1250+
-> Append (actual rows=3 loops=1)
1251+
Partition Selectors: $1
1252+
-> Seq Scan on delete_from_pt_1_prt_1 delete_from_pt_5 (actual rows=3 loops=1)
1253+
-> Seq Scan on delete_from_pt_1_prt_2 delete_from_pt_6 (never executed)
1254+
-> Seq Scan on delete_from_pt_1_prt_3 delete_from_pt_7 (never executed)
1255+
-> Hash (actual rows=1 loops=1)
1256+
Buckets: 262144 Batches: 1 Memory Usage: 2049kB
1257+
-> Partition Selector (selector id: $1) (actual rows=1 loops=1)
1258+
-> Broadcast Motion 3:3 (slice2; segments: 3) (actual rows=1 loops=1)
1259+
-> Seq Scan on t (actual rows=1 loops=1)
1260+
-> Hash (actual rows=5 loops=1)
12451261
Buckets: 131072 Batches: 1 Memory Usage: 1025kB
1246-
-> Partition Selector (selector id: $1) (actual rows=2 loops=1)
1247-
-> Broadcast Motion 3:3 (slice1; segments: 3) (actual rows=2 loops=1)
1248-
-> Hash Join (actual rows=1 loops=1)
1249-
Hash Cond: (delete_from_pt_1.b = t.a)
1250-
Extra Text: (seg0) Hash chain length 1.0 avg, 1 max, using 1 of 262144 buckets.
1251-
-> Append (actual rows=3 loops=1)
1252-
Partition Selectors: $2
1253-
-> Seq Scan on delete_from_pt_1_prt_1 delete_from_pt_5 (actual rows=3 loops=1)
1254-
-> Seq Scan on delete_from_pt_1_prt_2 delete_from_pt_6 (never executed)
1255-
-> Seq Scan on delete_from_pt_1_prt_3 delete_from_pt_7 (never executed)
1256-
-> Hash (actual rows=1 loops=1)
1257-
Buckets: 262144 Batches: 1 Memory Usage: 2049kB
1258-
-> Partition Selector (selector id: $2) (actual rows=1 loops=1)
1259-
-> Broadcast Motion 3:3 (slice2; segments: 3) (actual rows=1 loops=1)
1260-
-> Seq Scan on t (actual rows=1 loops=1)
1262+
-> Append (actual rows=5 loops=1)
1263+
-> Seq Scan on delete_from_pt_1_prt_1 delete_from_pt_2 (actual rows=3 loops=1)
1264+
-> Seq Scan on delete_from_pt_1_prt_2 delete_from_pt_3 (actual rows=3 loops=1)
1265+
-> Seq Scan on delete_from_pt_1_prt_3 delete_from_pt_4 (actual rows=0 loops=1)
12611266
Optimizer: Postgres query optimizer
1262-
(30 rows)
1267+
(28 rows)
12631268

12641269
SELECT * FROM delete_from_pt order by a;
12651270
a | b
@@ -1278,7 +1283,10 @@ RESET optimizer_trace_fallback;
12781283
-- CLEANUP
12791284
-- start_ignore
12801285
drop schema if exists bfv_partition_plans cascade;
1281-
NOTICE: drop cascades to 2 other objects
1286+
NOTICE: drop cascades to 5 other objects
12821287
DETAIL: drop cascades to function count_operator(text,text)
12831288
drop cascades to function find_operator(text,text)
1289+
drop cascades to table delete_from_indexed_pt
1290+
drop cascades to table delete_from_pt
1291+
drop cascades to table t
12841292
-- end_ignore

0 commit comments

Comments
 (0)