aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/subselect.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-11-25 16:20:12 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2016-11-25 16:20:31 -0500
commit474de765a8003bc58f5736f626bf533147cc1e68 (patch)
treef956d536c57772af290f2ea724c843f4981a858b /src/backend/optimizer/plan/subselect.c
parentbf5fe7bfa0e8bdc87be94b98bbdcb26054a6b75c (diff)
downloadpostgresql-474de765a8003bc58f5736f626bf533147cc1e68.tar.gz
postgresql-474de765a8003bc58f5736f626bf533147cc1e68.zip
Mark a query's topmost Paths parallel-unsafe if they will have initPlans.
Andreas Seltenreich found another case where we were being too optimistic about allowing a plan to be considered parallelizable despite it containing initPlans. It seems like the real issue here is that if we know we are going to tack initPlans onto the topmost Plan node for a subquery, we had better mark that subquery's result Paths as not-parallel-safe. That fixes this problem and allows reversion of a kluge (added in commit 7b67a0a49 and extended in f24cf960d) to not trust the parallel_safe flag at top level. Discussion: <874m2w4k5d.fsf@ex.ansel.ydns.eu>
Diffstat (limited to 'src/backend/optimizer/plan/subselect.c')
-rw-r--r--src/backend/optimizer/plan/subselect.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c
index 6edefb11388..f196db14299 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -2134,11 +2134,13 @@ SS_identify_outer_params(PlannerInfo *root)
}
/*
- * SS_charge_for_initplans - account for cost of initplans in Path costs
+ * SS_charge_for_initplans - account for initplans in Path costs & parallelism
*
* If any initPlans have been created in the current query level, they will
* get attached to the Plan tree created from whichever Path we select from
- * the given rel; so increment all the rel's Paths' costs to account for them.
+ * the given rel. Increment all that rel's Paths' costs to account for them,
+ * and make sure the paths get marked as parallel-unsafe, since we can't
+ * currently transmit initPlans to parallel workers.
*
* This is separate from SS_attach_initplans because we might conditionally
* create more initPlans during create_plan(), depending on which Path we
@@ -2170,7 +2172,7 @@ SS_charge_for_initplans(PlannerInfo *root, RelOptInfo *final_rel)
}
/*
- * Now adjust the costs.
+ * Now adjust the costs and parallel_safe flags.
*/
foreach(lc, final_rel->pathlist)
{
@@ -2178,6 +2180,7 @@ SS_charge_for_initplans(PlannerInfo *root, RelOptInfo *final_rel)
path->startup_cost += initplan_cost;
path->total_cost += initplan_cost;
+ path->parallel_safe = false;
}
/* We needn't do set_cheapest() here, caller will do it */