Code review for Parallel Append.

- Remove unnecessary #include mistakenly added in execnodes.h.
- Fix mistake in comment in choose_next_subplan_for_leader.
- Adjust row estimates in cost_append for a possibly-different
  parallel divisor.
- Clamp row estimates in cost_append after operations that may
  not produce integers.

Amit Kapila, with cosmetic adjustments by me.

Discussion: http://postgr.es/m/CAA4eK1+qcbeai3coPpRW=GFCzFeLUsuY4T-AKHqMjxpEGZBPQg@mail.gmail.com
This commit is contained in:
Robert Haas 2018-01-04 07:56:09 -05:00
parent 934c7986f4
commit c759395617
3 changed files with 15 additions and 9 deletions

View File

@ -446,10 +446,9 @@ choose_next_subplan_for_leader(AppendState *node)
* *
* We start from the first plan and advance through the list; * We start from the first plan and advance through the list;
* when we get back to the end, we loop back to the first * when we get back to the end, we loop back to the first
* nonpartial plan. This assigns the non-partial plans first * partial plan. This assigns the non-partial plans first in
* in order of descending cost and then spreads out the * order of descending cost and then spreads out the workers
* workers as evenly as possible across the remaining partial * as evenly as possible across the remaining partial plans.
* plans.
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
static bool static bool

View File

@ -1883,18 +1883,26 @@ cost_append(AppendPath *apath)
subpath->startup_cost); subpath->startup_cost);
/* /*
* Apply parallel divisor to non-partial subpaths. Also add the * Apply parallel divisor to subpaths. Scale the number of rows
* cost of partial paths to the total cost, but ignore non-partial * for each partial subpath based on the ratio of the parallel
* paths for now. * divisor originally used for the subpath to the one we adopted.
* Also add the cost of partial paths to the total cost, but
* ignore non-partial paths for now.
*/ */
if (i < apath->first_partial_path) if (i < apath->first_partial_path)
apath->path.rows += subpath->rows / parallel_divisor; apath->path.rows += subpath->rows / parallel_divisor;
else else
{ {
apath->path.rows += subpath->rows; double subpath_parallel_divisor;
subpath_parallel_divisor = get_parallel_divisor(subpath);
apath->path.rows += subpath->rows * (subpath_parallel_divisor /
parallel_divisor);
apath->path.total_cost += subpath->total_cost; apath->path.total_cost += subpath->total_cost;
} }
apath->path.rows = clamp_row_est(apath->path.rows);
i++; i++;
} }

View File

@ -21,7 +21,6 @@
#include "lib/pairingheap.h" #include "lib/pairingheap.h"
#include "nodes/params.h" #include "nodes/params.h"
#include "nodes/plannodes.h" #include "nodes/plannodes.h"
#include "storage/spin.h"
#include "utils/hsearch.h" #include "utils/hsearch.h"
#include "utils/queryenvironment.h" #include "utils/queryenvironment.h"
#include "utils/reltrigger.h" #include "utils/reltrigger.h"