From 31c7c642b6419b43eff903285e3da65e3f1901d6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 21 Jul 2012 17:45:07 -0400 Subject: 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. --- src/backend/optimizer/plan/planagg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/backend/optimizer/plan/planagg.c') 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; } -- cgit v1.2.3