Skip to content

Commit 7e187a7

Browse files
author
Richard Guo
committed
Fix unstable test in select_parallel.sql
One test case added in 22d946b verifies the plan of a non-parallel nestloop join. The planner's choice of join order is arbitrary, and slight variations in underlying statistics could result in a different displayed plan. To stabilize the test result, here we enforce the join order using a lateral join. While here, modify the test case to verify that parallel nestloop join is not generated if the inner path is not parallel-safe, which is what we wanted to test in 22d946b. Reported-by: Alexander Lakhin as per buildfarm Author: Richard Guo Discussion: https://postgr.es/m/[email protected]
1 parent 2d8ef5e commit 7e187a7

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/test/regress/expected/select_parallel.out

+11-6
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ reset enable_nestloop;
656656
-- test parallel nestloop join path with materialization of the inner path
657657
alter table tenk2 set (parallel_workers = 0);
658658
explain (costs off)
659-
select * from tenk1 t1, tenk2 t2 where t1.two > t2.two;
659+
select * from tenk1 t1, tenk2 t2 where t1.two > t2.two;
660660
QUERY PLAN
661661
-------------------------------------------
662662
Gather
@@ -668,18 +668,23 @@ explain (costs off)
668668
-> Seq Scan on tenk2 t2
669669
(7 rows)
670670

671-
-- the joinrel is not parallel-safe due to the OFFSET clause in the subquery
671+
-- test that parallel nestloop join is not generated if the inner path is
672+
-- not parallel-safe
672673
explain (costs off)
673-
select * from tenk1 t1, (select * from tenk2 t2 offset 0) t2 where t1.two > t2.two;
674+
select * from tenk1 t1
675+
left join lateral
676+
(select t1.unique1 as x, * from tenk2 t2 order by 1) t2
677+
on true
678+
where t1.two > t2.two;
674679
QUERY PLAN
675680
-------------------------------------------
676681
Nested Loop
677-
Join Filter: (t1.two > t2.two)
678682
-> Gather
679683
Workers Planned: 4
680684
-> Parallel Seq Scan on tenk1 t1
681-
-> Materialize
682-
-> Seq Scan on tenk2 t2
685+
-> Subquery Scan on t2
686+
Filter: (t1.two > t2.two)
687+
-> Seq Scan on tenk2 t2_1
683688
(7 rows)
684689

685690
alter table tenk2 reset (parallel_workers);

src/test/regress/sql/select_parallel.sql

+8-3
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,16 @@ reset enable_nestloop;
269269
-- test parallel nestloop join path with materialization of the inner path
270270
alter table tenk2 set (parallel_workers = 0);
271271
explain (costs off)
272-
select * from tenk1 t1, tenk2 t2 where t1.two > t2.two;
272+
select * from tenk1 t1, tenk2 t2 where t1.two > t2.two;
273273

274-
-- the joinrel is not parallel-safe due to the OFFSET clause in the subquery
274+
-- test that parallel nestloop join is not generated if the inner path is
275+
-- not parallel-safe
275276
explain (costs off)
276-
select * from tenk1 t1, (select * from tenk2 t2 offset 0) t2 where t1.two > t2.two;
277+
select * from tenk1 t1
278+
left join lateral
279+
(select t1.unique1 as x, * from tenk2 t2 order by 1) t2
280+
on true
281+
where t1.two > t2.two;
277282
alter table tenk2 reset (parallel_workers);
278283

279284
-- test gather merge

0 commit comments

Comments
 (0)