Improve the test case from 5668a857d
In commit 5668a857d, we fixed an issue with incorrect results in right semi joins and introduced a test case to verify the fix. The test case involves SubPlans and InitPlans, which may not be immediately apparent in relation to the issue we addressed. This patch simplifies the test case with a more straightforward query. Per discussion with Melanie Plageman. Author: Richard Guo Discussion: https://postgr.es/m/CAAKRu_a-Cip2XCXp13fmxq+T9BhLAVApHTyjr94awL2mbXHC-Q@mail.gmail.com
This commit is contained in:
parent
0172b4c944
commit
d8f335156c
@ -3041,63 +3041,39 @@ reset enable_nestloop;
|
|||||||
create temp table tbl_rs(a int, b int);
|
create temp table tbl_rs(a int, b int);
|
||||||
insert into tbl_rs select i, i from generate_series(1,10)i;
|
insert into tbl_rs select i, i from generate_series(1,10)i;
|
||||||
analyze tbl_rs;
|
analyze tbl_rs;
|
||||||
set enable_nestloop to off;
|
-- ensure we get a hash right semi join
|
||||||
set enable_hashagg to off;
|
|
||||||
-- ensure we get a hash right semi join with SubPlan in hash clauses
|
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
select * from tbl_rs t1
|
select * from tbl_rs t1 join
|
||||||
where (select a from tbl_rs t2
|
lateral (select * from tbl_rs t2 where t2.a in
|
||||||
where exists (select 1 from
|
(select t1.a+t3.a from tbl_rs t3) and t2.a < 5)
|
||||||
(select (b in (select b from tbl_rs t3)) as c from tbl_rs t4 where t4.a = 1) s
|
on true;
|
||||||
where c in (select t1.a = 1 from tbl_rs t5 union all select true))
|
QUERY PLAN
|
||||||
order by a limit 1) >= 0;
|
-------------------------------------------
|
||||||
QUERY PLAN
|
Nested Loop
|
||||||
--------------------------------------------------------------------------------------
|
-> Seq Scan on tbl_rs t1
|
||||||
Seq Scan on tbl_rs t1
|
-> Hash Right Semi Join
|
||||||
Filter: ((SubPlan 3) >= 0)
|
Hash Cond: ((t1.a + t3.a) = t2.a)
|
||||||
SubPlan 3
|
-> Seq Scan on tbl_rs t3
|
||||||
-> Limit
|
-> Hash
|
||||||
InitPlan 2
|
-> Seq Scan on tbl_rs t2
|
||||||
-> Hash Right Semi Join
|
Filter: (a < 5)
|
||||||
Hash Cond: (((t1.a = 1)) = (ANY (t4.b = (hashed SubPlan 1).col1)))
|
(8 rows)
|
||||||
-> Append
|
|
||||||
-> Seq Scan on tbl_rs t5
|
|
||||||
-> Result
|
|
||||||
-> Hash
|
|
||||||
-> Seq Scan on tbl_rs t4
|
|
||||||
Filter: (a = 1)
|
|
||||||
SubPlan 1
|
|
||||||
-> Seq Scan on tbl_rs t3
|
|
||||||
-> Sort
|
|
||||||
Sort Key: t2.a
|
|
||||||
-> Result
|
|
||||||
One-Time Filter: (InitPlan 2).col1
|
|
||||||
-> Seq Scan on tbl_rs t2
|
|
||||||
(20 rows)
|
|
||||||
|
|
||||||
-- and check we get the expected results
|
-- and check we get the expected results
|
||||||
select * from tbl_rs t1
|
select * from tbl_rs t1 join
|
||||||
where (select a from tbl_rs t2
|
lateral (select * from tbl_rs t2 where t2.a in
|
||||||
where exists (select 1 from
|
(select t1.a+t3.a from tbl_rs t3) and t2.a < 5)
|
||||||
(select (b in (select b from tbl_rs t3)) as c from tbl_rs t4 where t4.a = 1) s
|
on true;
|
||||||
where c in (select t1.a = 1 from tbl_rs t5 union all select true))
|
a | b | a | b
|
||||||
order by a limit 1) >= 0;
|
---+---+---+---
|
||||||
a | b
|
1 | 1 | 2 | 2
|
||||||
----+----
|
1 | 1 | 3 | 3
|
||||||
1 | 1
|
1 | 1 | 4 | 4
|
||||||
2 | 2
|
2 | 2 | 3 | 3
|
||||||
3 | 3
|
2 | 2 | 4 | 4
|
||||||
4 | 4
|
3 | 3 | 4 | 4
|
||||||
5 | 5
|
(6 rows)
|
||||||
6 | 6
|
|
||||||
7 | 7
|
|
||||||
8 | 8
|
|
||||||
9 | 9
|
|
||||||
10 | 10
|
|
||||||
(10 rows)
|
|
||||||
|
|
||||||
reset enable_nestloop;
|
|
||||||
reset enable_hashagg;
|
|
||||||
--
|
--
|
||||||
-- regression test for bug #13908 (hash join with skew tuples & nbatch increase)
|
-- regression test for bug #13908 (hash join with skew tuples & nbatch increase)
|
||||||
--
|
--
|
||||||
|
@ -741,32 +741,23 @@ reset enable_nestloop;
|
|||||||
--
|
--
|
||||||
-- regression test for bug with hash-right-semi join
|
-- regression test for bug with hash-right-semi join
|
||||||
--
|
--
|
||||||
|
|
||||||
create temp table tbl_rs(a int, b int);
|
create temp table tbl_rs(a int, b int);
|
||||||
insert into tbl_rs select i, i from generate_series(1,10)i;
|
insert into tbl_rs select i, i from generate_series(1,10)i;
|
||||||
analyze tbl_rs;
|
analyze tbl_rs;
|
||||||
|
|
||||||
set enable_nestloop to off;
|
-- ensure we get a hash right semi join
|
||||||
set enable_hashagg to off;
|
|
||||||
|
|
||||||
-- ensure we get a hash right semi join with SubPlan in hash clauses
|
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
select * from tbl_rs t1
|
select * from tbl_rs t1 join
|
||||||
where (select a from tbl_rs t2
|
lateral (select * from tbl_rs t2 where t2.a in
|
||||||
where exists (select 1 from
|
(select t1.a+t3.a from tbl_rs t3) and t2.a < 5)
|
||||||
(select (b in (select b from tbl_rs t3)) as c from tbl_rs t4 where t4.a = 1) s
|
on true;
|
||||||
where c in (select t1.a = 1 from tbl_rs t5 union all select true))
|
|
||||||
order by a limit 1) >= 0;
|
|
||||||
|
|
||||||
-- and check we get the expected results
|
-- and check we get the expected results
|
||||||
select * from tbl_rs t1
|
select * from tbl_rs t1 join
|
||||||
where (select a from tbl_rs t2
|
lateral (select * from tbl_rs t2 where t2.a in
|
||||||
where exists (select 1 from
|
(select t1.a+t3.a from tbl_rs t3) and t2.a < 5)
|
||||||
(select (b in (select b from tbl_rs t3)) as c from tbl_rs t4 where t4.a = 1) s
|
on true;
|
||||||
where c in (select t1.a = 1 from tbl_rs t5 union all select true))
|
|
||||||
order by a limit 1) >= 0;
|
|
||||||
|
|
||||||
reset enable_nestloop;
|
|
||||||
reset enable_hashagg;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- regression test for bug #13908 (hash join with skew tuples & nbatch increase)
|
-- regression test for bug #13908 (hash join with skew tuples & nbatch increase)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user