aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/planagg.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-07-21 17:45:07 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-07-21 17:45:07 -0400
commit31c7c642b6419b43eff903285e3da65e3f1901d6 (patch)
treef7c172f0de2d1692289f484e642f85ed01bb40c5 /src/backend/optimizer/plan/planagg.c
parented0af3324702685cce63aed0641b4cbb45816b50 (diff)
downloadpostgresql-31c7c642b6419b43eff903285e3da65e3f1901d6.tar.gz
postgresql-31c7c642b6419b43eff903285e3da65e3f1901d6.zip
Account for SRFs in targetlists in planner rowcount estimates.
We made use of the ROWS estimate for set-returning functions used in FROM, but not for those used in SELECT targetlists; which is a bit of an oversight considering there are common usages that require the latter approach. Improve that. (I had initially thought it might be worth folding this into cost_qual_eval, but after investigation concluded that that wouldn't be very helpful, so just do it separately.) Per complaint from David Johnston. Back-patch to 9.2, but not further, for fear of destabilizing plan choices in existing releases.
Diffstat (limited to 'src/backend/optimizer/plan/planagg.c')
-rw-r--r--src/backend/optimizer/plan/planagg.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/planagg.c b/src/backend/optimizer/plan/planagg.c
index be52d16ff06..0bbca071fb0 100644
--- a/src/backend/optimizer/plan/planagg.c
+++ b/src/backend/optimizer/plan/planagg.c
@@ -36,6 +36,7 @@
#include "optimizer/cost.h"
#include "optimizer/paths.h"
#include "optimizer/planmain.h"
+#include "optimizer/planner.h"
#include "optimizer/subselect.h"
#include "parser/parsetree.h"
#include "parser/parse_clause.h"
@@ -205,7 +206,6 @@ optimize_minmax_aggregates(PlannerInfo *root, List *tlist,
Path agg_p;
Plan *plan;
Node *hqual;
- QualCost tlist_cost;
ListCell *lc;
/* Nothing to do if preprocess_minmax_aggs rejected the query */
@@ -272,9 +272,7 @@ optimize_minmax_aggregates(PlannerInfo *root, List *tlist,
plan = (Plan *) make_result(root, tlist, hqual, NULL);
/* Account for evaluation cost of the tlist (make_result did the rest) */
- cost_qual_eval(&tlist_cost, tlist, root);
- plan->startup_cost += tlist_cost.startup;
- plan->total_cost += tlist_cost.startup + tlist_cost.per_tuple;
+ add_tlist_costs_to_plan(root, plan, tlist);
return plan;
}