Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 24d08f3

Browse files
committed
Fix mark-and-restore-skipping test case to not be a self-join.
There isn't any good reason for this test to be a self-join rather than a join between separate tables, except that it saved a couple of SQL commands for setup. A proposed patch to optimize away self-joins breaks the test, so adjust it to avoid that happening. Discussion: https://postgr.es/m/64486b0b-0404-e39e-322d-0801154901f3@postgrespro.ru
1 parent 0c7d537 commit 24d08f3

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/test/regress/expected/join.out

+12-8
Original file line numberDiff line numberDiff line change
@@ -5932,22 +5932,26 @@ left join j2 on j1.id1 = j2.id1 where j1.id2 = 1;
59325932
set enable_nestloop to 0;
59335933
set enable_hashjoin to 0;
59345934
set enable_sort to 0;
5935-
-- create an index that will be preferred over the PK to perform the join
5935+
-- create indexes that will be preferred over the PKs to perform the join
59365936
create index j1_id1_idx on j1 (id1) where id1 % 1000 = 1;
5937-
explain (costs off) select * from j1 j1
5938-
inner join j1 j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
5937+
create index j2_id1_idx on j2 (id1) where id1 % 1000 = 1;
5938+
-- need an additional row in j2, if we want j2_id1_idx to be preferred
5939+
insert into j2 values(1,2);
5940+
analyze j2;
5941+
explain (costs off) select * from j1
5942+
inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
59395943
where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;
5940-
QUERY PLAN
5941-
--------------------------------------------
5944+
QUERY PLAN
5945+
-----------------------------------------
59425946
Merge Join
59435947
Merge Cond: (j1.id1 = j2.id1)
59445948
Join Filter: (j1.id2 = j2.id2)
59455949
-> Index Scan using j1_id1_idx on j1
5946-
-> Index Scan using j1_id1_idx on j1 j2
5950+
-> Index Scan using j2_id1_idx on j2
59475951
(5 rows)
59485952

5949-
select * from j1 j1
5950-
inner join j1 j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
5953+
select * from j1
5954+
inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
59515955
where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;
59525956
id1 | id2 | id1 | id2
59535957
-----+-----+-----+-----

src/test/regress/sql/join.sql

+10-5
Original file line numberDiff line numberDiff line change
@@ -2014,15 +2014,20 @@ set enable_nestloop to 0;
20142014
set enable_hashjoin to 0;
20152015
set enable_sort to 0;
20162016

2017-
-- create an index that will be preferred over the PK to perform the join
2017+
-- create indexes that will be preferred over the PKs to perform the join
20182018
create index j1_id1_idx on j1 (id1) where id1 % 1000 = 1;
2019+
create index j2_id1_idx on j2 (id1) where id1 % 1000 = 1;
20192020

2020-
explain (costs off) select * from j1 j1
2021-
inner join j1 j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
2021+
-- need an additional row in j2, if we want j2_id1_idx to be preferred
2022+
insert into j2 values(1,2);
2023+
analyze j2;
2024+
2025+
explain (costs off) select * from j1
2026+
inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
20222027
where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;
20232028

2024-
select * from j1 j1
2025-
inner join j1 j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
2029+
select * from j1
2030+
inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
20262031
where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;
20272032

20282033
reset enable_nestloop;

0 commit comments

Comments
 (0)