summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/relation.h14
-rw-r--r--src/include/optimizer/clauses.h10
-rw-r--r--src/include/optimizer/cost.h4
-rw-r--r--src/include/optimizer/planmain.h8
4 files changed, 22 insertions, 14 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
diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h
index 7ae236d167c..4af772d255c 100644
--- a/src/include/optimizer/clauses.h
+++ b/src/include/optimizer/clauses.h
@@ -22,13 +22,6 @@
typedef struct
{
- int numAggs; /* total number of aggregate calls */
- int numOrderedAggs; /* number that use DISTINCT or ORDER BY */
- Size transitionSpace; /* for pass-by-ref transition data */
-} AggClauseCounts;
-
-typedef struct
-{
int numWindowFuncs; /* total number of WindowFuncs found */
Index maxWinRef; /* windowFuncs[] is indexed 0 .. maxWinRef */
List **windowFuncs; /* lists of WindowFuncs for each winref */
@@ -56,7 +49,8 @@ extern List *make_ands_implicit(Expr *clause);
extern bool contain_agg_clause(Node *clause);
extern List *pull_agg_clause(Node *clause);
-extern void count_agg_clauses(Node *clause, AggClauseCounts *counts);
+extern void count_agg_clauses(PlannerInfo *root, Node *clause,
+ AggClauseCosts *costs);
extern bool contain_window_function(Node *clause);
extern WindowFuncLists *find_window_functions(Node *clause, Index maxWinRef);
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
index 08898c13b9f..2763863af27 100644
--- a/src/include/optimizer/cost.h
+++ b/src/include/optimizer/cost.h
@@ -94,12 +94,12 @@ extern void cost_material(Path *path,
Cost input_startup_cost, Cost input_total_cost,
double tuples, int width);
extern void cost_agg(Path *path, PlannerInfo *root,
- AggStrategy aggstrategy, int numAggs,
+ AggStrategy aggstrategy, const AggClauseCosts *aggcosts,
int numGroupCols, double numGroups,
Cost input_startup_cost, Cost input_total_cost,
double input_tuples);
extern void cost_windowagg(Path *path, PlannerInfo *root,
- int numWindowFuncs, int numPartCols, int numOrderCols,
+ List *windowFuncs, int numPartCols, int numOrderCols,
Cost input_startup_cost, Cost input_total_cost,
double input_tuples);
extern void cost_group(Path *path, PlannerInfo *root,
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
index d48bf39e410..5261691af69 100644
--- a/src/include/optimizer/planmain.h
+++ b/src/include/optimizer/planmain.h
@@ -34,7 +34,7 @@ extern void query_planner(PlannerInfo *root, List *tlist,
*/
extern void preprocess_minmax_aggregates(PlannerInfo *root, List *tlist);
extern Plan *optimize_minmax_aggregates(PlannerInfo *root, List *tlist,
- Path *best_path);
+ const AggClauseCosts *aggcosts, Path *best_path);
/*
* prototypes for plan/createplan.c
@@ -54,12 +54,12 @@ extern Sort *make_sort_from_sortclauses(PlannerInfo *root, List *sortcls,
extern Sort *make_sort_from_groupcols(PlannerInfo *root, List *groupcls,
AttrNumber *grpColIdx, Plan *lefttree);
extern Agg *make_agg(PlannerInfo *root, List *tlist, List *qual,
- AggStrategy aggstrategy,
+ AggStrategy aggstrategy, const AggClauseCosts *aggcosts,
int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators,
- long numGroups, int numAggs,
+ long numGroups,
Plan *lefttree);
extern WindowAgg *make_windowagg(PlannerInfo *root, List *tlist,
- int numWindowFuncs, Index winref,
+ List *windowFuncs, Index winref,
int partNumCols, AttrNumber *partColIdx, Oid *partOperators,
int ordNumCols, AttrNumber *ordColIdx, Oid *ordOperators,
int frameOptions, Node *startOffset, Node *endOffset,