Skip to content

Commit 7b2029d

Browse files
committed
Add more scan methods to the parallel temp scan code.
1 parent 91ab602 commit 7b2029d

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

contrib/tempscan/nodeCustomTempScan.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ create_partial_tempscan_path(PlannerInfo *root, RelOptInfo *rel,
102102
pathnode->parallel_workers = path->parallel_workers;
103103

104104
/* DEBUGGING purposes only */
105-
pathnode->startup_cost = path->startup_cost /*/ disable_cost*/;
106-
pathnode->total_cost = path->total_cost /*/ disable_cost*/;
105+
pathnode->startup_cost = path->startup_cost;
106+
pathnode->total_cost = path->total_cost;
107107

108108
cpath->custom_paths = list_make1(path);
109109
cpath->custom_private = NIL;
@@ -206,7 +206,8 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
206206
RangeTblEntry *rte)
207207
{
208208
int parallel_workers;
209-
Path *path;
209+
ListCell *lc;
210+
List *partial_pathlist_new = NIL;
210211

211212
/*
212213
* Some extension intercept this hook earlier. Allow it to do a work
@@ -234,16 +235,33 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
234235
if (parallel_workers <= 0)
235236
return;
236237

238+
/* Enable parallel paths generation for this relation */
239+
Assert(rel->partial_pathlist == NIL);
237240
rel->consider_parallel = true;
238241

239-
path = create_seqscan_path(root, rel, NULL, parallel_workers);
240-
if (path)
242+
/* Add partial sequental scan path. */
243+
add_partial_path(rel, (Path *)
244+
create_seqscan_path(root, rel, NULL, parallel_workers));
245+
246+
/* Add there more specific paths too */
247+
create_index_paths(root, rel);
248+
create_tidscan_paths(root, rel);
249+
250+
foreach(lc, rel->partial_pathlist)
241251
{
242-
/* Add an unordered partial path based on a parallel sequential scan. */
243-
add_partial_path(rel, (Path *)
244-
create_partial_tempscan_path(root, rel, path));
252+
Path *path = lfirst(lc);
253+
254+
partial_pathlist_new =
255+
lappend(partial_pathlist_new,
256+
(void *) create_partial_tempscan_path(root, rel, path));
245257
}
246258

259+
/*
260+
* Dangerous zone. But we assume it is strictly local. What about extension
261+
* which could call ours and add some paths after us?
262+
*/
263+
rel->partial_pathlist = partial_pathlist_new;
264+
247265
Assert(IsA(linitial(rel->partial_pathlist), CustomPath));
248266
}
249267

contrib/tempscan/sql/basic.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ SELECT count(*) FROM parallel_test t1 NATURAL JOIN parallel_test t2;
4242
EXPLAIN (COSTS OFF)
4343
SELECT count(*) FROM parallel_test_tmp t1 NATURAL JOIN parallel_test t2;
4444

45+
-- TODO: Tests on parallel index scan
46+
4547
RESET enable_hashjoin;
4648
RESET tempscan.enable;
4749
DROP TABLE parallel_test, parallel_test_tmp;

0 commit comments

Comments
 (0)