@@ -168,5 +168,75 @@ WHERE t1.x < 10;
168168 Filter: (y = t1.y)
169169(9 rows)
170170
171+ -- Employ parallel join using CustomScan as an inner
172+ EXPLAIN (COSTS OFF)
173+ SELECT count(*) FROM parallel_test t1 NATURAL JOIN parallel_test_tmp_2 t2
174+ WHERE t1.x < 10;
175+ QUERY PLAN
176+ ----------------------------------------------------------------------------------------------
177+ Aggregate
178+ -> Gather
179+ Workers Planned: 3
180+ -> Nested Loop
181+ -> Parallel Seq Scan on parallel_test t1
182+ Filter: (x < 10)
183+ -> Custom Scan (nodeCustomTempScan)
184+ -> Index Scan using parallel_test_tmp_2_x_idx on parallel_test_tmp_2 t2
185+ Index Cond: (x = t1.x)
186+ Filter: (t1.y = y)
187+ (10 rows)
188+
189+ -- Check real execution
190+ EXPLAIN (VERBOSE, COSTS OFF)
191+ SELECT count(*) FROM parallel_test t1 NATURAL JOIN parallel_test_tmp_2 t2;
192+ QUERY PLAN
193+ --------------------------------------------------------------------------
194+ Aggregate
195+ Output: count(*)
196+ -> Gather
197+ Workers Planned: 3
198+ -> Hash Join
199+ Hash Cond: ((t1.x = t2.x) AND (t1.y = t2.y))
200+ -> Parallel Seq Scan on public.parallel_test t1
201+ Output: t1.x, t1.y
202+ -> Hash
203+ Output: t2.x, t2.y
204+ -> Custom Scan (nodeCustomTempScan)
205+ Output: t2.x, t2.y
206+ -> Seq Scan on pg_temp.parallel_test_tmp_2 t2
207+ Output: t2.x, t2.y
208+ (14 rows)
209+
210+ SET max_parallel_workers_per_gather = 0;
211+ SELECT count(*) FROM parallel_test t1 NATURAL JOIN parallel_test_tmp_2 t2;
212+ count
213+ -------
214+ 10100
215+ (1 row)
216+
217+ SET max_parallel_workers_per_gather = 3;
218+ EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
219+ SELECT count(*) FROM parallel_test t1 NATURAL JOIN parallel_test_tmp_2 t2;
220+ QUERY PLAN
221+ ----------------------------------------------------------------------------------------------
222+ Aggregate (actual rows=1 loops=1)
223+ -> Gather (actual rows=10100 loops=1)
224+ Workers Planned: 3
225+ Workers Launched: 3
226+ -> Hash Join (actual rows=2525 loops=4)
227+ Hash Cond: ((t1.x = t2.x) AND (t1.y = t2.y))
228+ -> Parallel Seq Scan on parallel_test t1 (actual rows=2525 loops=4)
229+ -> Hash (actual rows=10100 loops=4)
230+ Buckets: 16384 Batches: 1 Memory Usage: 571kB
231+ -> Custom Scan (nodeCustomTempScan) (actual rows=10100 loops=4)
232+ -> Seq Scan on parallel_test_tmp_2 t2 (actual rows=10100 loops=1)
233+ (11 rows)
234+
235+ SELECT count(*) FROM parallel_test t1 NATURAL JOIN parallel_test_tmp_2 t2;
236+ count
237+ -------
238+ 10100
239+ (1 row)
240+
171241RESET tempscan.enable;
172242DROP TABLE parallel_test, parallel_test_tmp;
0 commit comments