summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2002-11-19 23:22:00 +0000
committerTom Lane2002-11-19 23:22:00 +0000
commitb60be3f2f8d094da79e04c6eda888f401b09dc39 (patch)
tree0590e0647deb5041b8dabcabf03770ebef8e8d43 /src/include
parent54cb1db6cf4d4bf4e44148582bbd2c99684e7dfd (diff)
Add an at-least-marginally-plausible method of estimating the number
of groups produced by GROUP BY. This improves the accuracy of planning estimates for grouped subselects, and is needed to check whether a hashed aggregation plan risks memory overflow.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/parsenodes.h3
-rw-r--r--src/include/optimizer/planmain.h10
-rw-r--r--src/include/utils/selfuncs.h5
3 files changed, 13 insertions, 5 deletions
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index cd976cd1a14..92501196f93 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.215 2002/11/15 03:09:39 momjian Exp $
+ * $Id: parsenodes.h,v 1.216 2002/11/19 23:21:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -102,6 +102,7 @@ typedef struct Query
List *equi_key_list; /* list of lists of equijoined
* PathKeyItems */
List *query_pathkeys; /* desired pathkeys for query_planner() */
+ bool hasJoinRTEs; /* true if any RTEs are RTE_JOIN kind */
} Query;
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
index c927d540740..bd4bcddd308 100644
--- a/src/include/optimizer/planmain.h
+++ b/src/include/optimizer/planmain.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: planmain.h,v 1.61 2002/11/06 00:00:45 tgl Exp $
+ * $Id: planmain.h,v 1.62 2002/11/19 23:22:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,8 +35,11 @@ extern Sort *make_sort(Query *root, List *tlist,
extern Sort *make_sort_from_pathkeys(Query *root, List *tlist,
Plan *lefttree, List *pathkeys);
extern Agg *make_agg(List *tlist, List *qual, AggStrategy aggstrategy,
- int ngrp, AttrNumber *grpColIdx, Plan *lefttree);
-extern Group *make_group(List *tlist, int ngrp, AttrNumber *grpColIdx,
+ int ngrp, AttrNumber *grpColIdx,
+ long numGroups, int numAggs,
+ Plan *lefttree);
+extern Group *make_group(List *tlist,
+ int ngrp, AttrNumber *grpColIdx, double numGroups,
Plan *lefttree);
extern Material *make_material(List *tlist, Plan *lefttree);
extern Unique *make_unique(List *tlist, Plan *lefttree, List *distinctList);
@@ -54,6 +57,7 @@ extern void build_base_rel_tlists(Query *root, List *tlist);
extern Relids distribute_quals_to_rels(Query *root, Node *jtnode);
extern void process_implied_equality(Query *root, Node *item1, Node *item2,
Oid sortop1, Oid sortop2);
+extern bool vars_known_equal(Query *root, Var *var1, Var *var2);
/*
* prototypes for plan/setrefs.c
diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h
index 8e73e61ffdc..49f3bc7e005 100644
--- a/src/include/utils/selfuncs.h
+++ b/src/include/utils/selfuncs.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: selfuncs.h,v 1.9 2002/10/19 02:56:16 tgl Exp $
+ * $Id: selfuncs.h,v 1.10 2002/11/19 23:22:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -75,6 +75,9 @@ extern void mergejoinscansel(Query *root, Node *clause,
Selectivity *leftscan,
Selectivity *rightscan);
+extern double estimate_num_groups(Query *root, List *groupClauses,
+ double input_rows);
+
extern Datum btcostestimate(PG_FUNCTION_ARGS);
extern Datum rtcostestimate(PG_FUNCTION_ARGS);
extern Datum hashcostestimate(PG_FUNCTION_ARGS);