Skip to content

Commit 0e495c5

Browse files
committed
Set correct cost data in Gather node added by force_parallel_mode.
We were just leaving the cost fields zeroes, which produces obviously bogus output with force_parallel_mode = on. With force_parallel_mode = regress, the zeroes are hidden, but I wonder if they wouldn't still confuse add-on code such as auto_explain.
1 parent c89d507 commit 0e495c5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/backend/optimizer/plan/planner.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,22 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
343343
gather->num_workers = 1;
344344
gather->single_copy = true;
345345
gather->invisible = (force_parallel_mode == FORCE_PARALLEL_REGRESS);
346+
347+
/*
348+
* Ideally we'd use cost_gather here, but setting up dummy path data
349+
* to satisfy it doesn't seem much cleaner than knowing what it does.
350+
*/
351+
gather->plan.startup_cost = top_plan->startup_cost +
352+
parallel_setup_cost;
353+
gather->plan.total_cost = top_plan->total_cost +
354+
parallel_setup_cost + parallel_tuple_cost * top_plan->plan_rows;
355+
gather->plan.plan_rows = top_plan->plan_rows;
356+
gather->plan.plan_width = top_plan->plan_width;
357+
gather->plan.parallel_aware = false;
358+
359+
/* use parallel mode for parallel plans. */
346360
root->glob->parallelModeNeeded = true;
361+
347362
top_plan = &gather->plan;
348363
}
349364

0 commit comments

Comments
 (0)