From e6a30a8c3c81a7a2949f852379d34a19dfc26a0d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 24 Apr 2011 16:55:20 -0400 Subject: Improve cost estimation for aggregates and window functions. The previous coding failed to account properly for the costs of evaluating the input expressions of aggregates and window functions, as seen in a recent gripe from Claudio Freire. (I said at the time that it wasn't counting these costs at all; but on closer inspection, it was effectively charging these costs once per output tuple. That is completely wrong for aggregates, and not exactly right for window functions either.) There was also a hard-wired assumption that aggregates and window functions had procost 1.0, which is now fixed to respect the actual cataloged costs. The costing of WindowAgg is still pretty bogus, since it doesn't try to estimate the effects of spilling data to disk, but that seems like a separate issue. --- src/backend/optimizer/util/pathnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/backend/optimizer/util/pathnode.c') diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 55218b58694..161d5ab122e 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -1103,7 +1103,7 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, all_hash = false; /* don't try to hash */ else cost_agg(&agg_path, root, - AGG_HASHED, 0, + AGG_HASHED, NULL, numCols, pathnode->rows, subpath->startup_cost, subpath->total_cost, -- cgit v1.2.3