aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/util/pathnode.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-03-08 16:28:27 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2016-03-08 16:28:34 -0500
commit8c314b9853c2fbb85c041d4761426f25a9d63972 (patch)
tree4f8f5c1ac067589c112c71f25331e79ae0147e56 /src/backend/optimizer/util/pathnode.c
parent7400559a3fe959bdc6822114ef6aa966c42899f9 (diff)
downloadpostgresql-8c314b9853c2fbb85c041d4761426f25a9d63972.tar.gz
postgresql-8c314b9853c2fbb85c041d4761426f25a9d63972.zip
Finish refactoring make_foo() functions in createplan.c.
This patch removes some redundant cost calculations that I left for later cleanup in commit 3fc6e2d7f5b652b4. There's now a uniform policy that the make_foo() convenience functions don't do any cost calculations. Most of their callers copy costs from the source Path node, and for those that don't, the calculation in the make_foo() function wasn't necessarily right anyhow. (make_result() was particularly a mess, as it was serving multiple callers using cost calcs designed for only the first one or two that had ever existed.) Aside from saving a few cycles, this ensures that what EXPLAIN prints matches the costs we used for planning purposes. It does not change any planner decisions, since the decisions are already made.
Diffstat (limited to 'src/backend/optimizer/util/pathnode.c')
-rw-r--r--src/backend/optimizer/util/pathnode.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
index 19c15709a45..fe5e830385a 100644
--- a/src/backend/optimizer/util/pathnode.c
+++ b/src/backend/optimizer/util/pathnode.c
@@ -1328,7 +1328,8 @@ create_merge_append_path(PlannerInfo *root,
* jointree.
*/
ResultPath *
-create_result_path(RelOptInfo *rel, PathTarget *target, List *quals)
+create_result_path(PlannerInfo *root, RelOptInfo *rel,
+ PathTarget *target, List *resconstantqual)
{
ResultPath *pathnode = makeNode(ResultPath);
@@ -1340,23 +1341,22 @@ create_result_path(RelOptInfo *rel, PathTarget *target, List *quals)
pathnode->path.parallel_safe = rel->consider_parallel;
pathnode->path.parallel_degree = 0;
pathnode->path.pathkeys = NIL;
- pathnode->quals = quals;
+ pathnode->quals = resconstantqual;
/* Hardly worth defining a cost_result() function ... just do it */
pathnode->path.rows = 1;
pathnode->path.startup_cost = target->cost.startup;
pathnode->path.total_cost = target->cost.startup +
cpu_tuple_cost + target->cost.per_tuple;
+ if (resconstantqual)
+ {
+ QualCost qual_cost;
- /*
- * In theory we should include the qual eval cost as well, but at present
- * that doesn't accomplish much except duplicate work that will be done
- * again in make_result; since this is only used for degenerate cases,
- * nothing interesting will be done with the path cost values.
- *
- * XXX should refactor so that make_result does not do costing work, at
- * which point this will need to do it honestly.
- */
+ cost_qual_eval(&qual_cost, resconstantqual, root);
+ /* resconstantqual is evaluated once at startup */
+ pathnode->path.startup_cost += qual_cost.startup + qual_cost.per_tuple;
+ pathnode->path.total_cost += qual_cost.startup + qual_cost.per_tuple;
+ }
return pathnode;
}
@@ -2162,7 +2162,7 @@ create_projection_path(PlannerInfo *root,
/*
* The Result node's cost is cpu_tuple_cost per row, plus the cost of
- * evaluating the tlist.
+ * evaluating the tlist. There is no qual to worry about.
*/
pathnode->path.rows = subpath->rows;
pathnode->path.startup_cost = subpath->startup_cost + target->cost.startup;