summaryrefslogtreecommitdiff
path: root/src/backend/optimizer
diff options
context:
space:
mode:
authorRobert Haas2018-01-04 12:56:09 +0000
committerRobert Haas2018-01-04 12:56:09 +0000
commitc759395617765c5bc21db149cf8c3df52f41ccff (patch)
tree73356a7d1789173f7867f55f5d50a71138c6fc34 /src/backend/optimizer
parent934c7986f4a0a6a3b606301d84b784a27c0c324b (diff)
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
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r--src/backend/optimizer/path/costsize.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
index 7903b2cb167..8679b14b29a 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -1883,18 +1883,26 @@ cost_append(AppendPath *apath)
subpath->startup_cost);
/*
- * Apply parallel divisor to non-partial subpaths. Also add the
- * cost of partial paths to the total cost, but ignore non-partial
- * paths for now.
+ * Apply parallel divisor to subpaths. Scale the number of rows
+ * for each partial subpath based on the ratio of the parallel
+ * 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)
apath->path.rows += subpath->rows / parallel_divisor;
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.rows = clamp_row_est(apath->path.rows);
+
i++;
}