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

Commit 110a6db

Browse files
committed
Allow RTE_SUBQUERY rels to be considered parallel-safe.
There isn't really any reason not to; the original comments here were partly confused about subplans versus subquery-in-FROM, and partly dependent on restrictions that no longer apply now that subqueries return Paths not Plans. Depending on what's inside the subquery, it might fail to produce any parallel_safe Paths, but that's fine. Tom Lane and Robert Haas
1 parent 4ea9948 commit 110a6db

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/backend/optimizer/path/allpaths.c

+12-8
Original file line numberDiff line numberDiff line change
@@ -575,15 +575,19 @@ set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel,
575575
case RTE_SUBQUERY:
576576

577577
/*
578-
* Subplans currently aren't passed to workers. Even if they
579-
* were, the subplan might be using parallelism internally, and we
580-
* can't support nested Gather nodes at present. Finally, we
581-
* don't have a good way of knowing whether the subplan involves
582-
* any parallel-restricted operations. It would be nice to relax
583-
* this restriction some day, but it's going to take a fair amount
584-
* of work.
578+
* There's no intrinsic problem with scanning a subquery-in-FROM
579+
* (as distinct from a SubPlan or InitPlan) in a parallel worker.
580+
* If the subquery doesn't happen to have any parallel-safe paths,
581+
* then flagging it as consider_parallel won't change anything,
582+
* but that's true for plain tables, too. We must set
583+
* consider_parallel based on the rel's own quals and targetlist,
584+
* so that if a subquery path is parallel-safe but the quals and
585+
* projection we're sticking onto it are not, we correctly mark
586+
* the SubqueryScanPath as not parallel-safe. (Note that
587+
* set_subquery_pathlist() might push some of these quals down
588+
* into the subquery itself, but that doesn't change anything.)
585589
*/
586-
return;
590+
break;
587591

588592
case RTE_JOIN:
589593
/* Shouldn't happen; we're only considering baserels here. */

0 commit comments

Comments
 (0)