diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-11-25 16:20:12 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-11-25 16:20:12 -0500 |
commit | ab77a5a4561fad847af4a101a29c922c66449870 (patch) | |
tree | 7f9d5a345c454232859e3b6847e8b02b4323e692 /src/backend/optimizer/plan/planner.c | |
parent | 4e026b32d4024b03856b4981b26c747b7fef7afb (diff) | |
download | postgresql-ab77a5a4561fad847af4a101a29c922c66449870.tar.gz postgresql-ab77a5a4561fad847af4a101a29c922c66449870.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/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index a8847defba3..41dde50d854 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -341,12 +341,9 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) * Optionally add a Gather node for testing purposes, provided this is * actually a safe thing to do. (Note: we assume adding a Material node * above did not change the parallel safety of the plan, so we can still - * rely on best_path->parallel_safe. However, that flag doesn't account - * for subplans, which we are unable to transmit to workers presently.) + * rely on best_path->parallel_safe.) */ - if (force_parallel_mode != FORCE_PARALLEL_OFF && - best_path->parallel_safe && - glob->subplans == NIL) + if (force_parallel_mode != FORCE_PARALLEL_OFF && best_path->parallel_safe) { Gather *gather = makeNode(Gather); @@ -801,10 +798,10 @@ subquery_planner(PlannerGlobal *glob, Query *parse, SS_identify_outer_params(root); /* - * If any initPlans were created in this query level, increment the - * surviving Paths' costs to account for them. They won't actually get - * attached to the plan tree till create_plan() runs, but we want to be - * sure their costs are included now. + * If any initPlans were created in this query level, adjust the surviving + * Paths' costs and parallel-safety flags to account for them. The + * initPlans won't actually get attached to the plan tree till + * create_plan() runs, but we must include their effects now. */ final_rel = fetch_upper_rel(root, UPPERREL_FINAL, NULL); SS_charge_for_initplans(root, final_rel); |