summaryrefslogtreecommitdiff
path: root/src/include/nodes/relation.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-04-24 16:55:20 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-04-24 16:55:20 -0400
commite6a30a8c3c81a7a2949f852379d34a19dfc26a0d (patch)
treed6abe75c107e16a658e565f08e77983ce22c9495 /src/include/nodes/relation.h
parentf6322b31918c5c57eeea80c26a088af44d573095 (diff)
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.
Diffstat (limited to 'src/include/nodes/relation.h')
-rw-r--r--src/include/nodes/relation.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index 78b03e024e8..f6592697e44 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -46,6 +46,20 @@ typedef struct QualCost
Cost per_tuple; /* per-evaluation cost */
} QualCost;
+/*
+ * Costing aggregate function execution requires these statistics about
+ * the aggregates to be executed by a given Agg node. Note that transCost
+ * includes the execution costs of the aggregates' input expressions.
+ */
+typedef struct AggClauseCosts
+{
+ int numAggs; /* total number of aggregate functions */
+ int numOrderedAggs; /* number that use DISTINCT or ORDER BY */
+ QualCost transCost; /* total per-input-row execution costs */
+ Cost finalCost; /* total costs of agg final functions */
+ Size transitionSpace; /* space for pass-by-ref transition data */
+} AggClauseCosts;
+
/*----------
* PlannerGlobal