summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2005-08-27 22:13:44 +0000
committerTom Lane2005-08-27 22:13:44 +0000
commit4e5fbb34b361102df41642a6ed9676b8b6a1e75f (patch)
tree56acd956f301ecd6f33904d5ac05d984ac6bd413 /src/include
parent9e56c5a4cff7edb145729c7ba2b19dd8cf1c45cf (diff)
Change the division of labor between grouping_planner and query_planner
so that the latter estimates the number of groups that grouping will produce. This is needed because it is primarily query_planner that makes the decision between fast-start and fast-finish plans, and in the original coding it was unable to make more than a crude rule-of-thumb choice when the query involved grouping. This revision helps us make saner choices for queries like SELECT ... GROUP BY ... LIMIT, as in a recent example from Mark Kirkwood. Also move the responsibility for canonicalizing sort_pathkeys and group_pathkeys into query_planner; this information has to be available anyway to support the first change, and doing it this way lets us get rid of compare_noncanonical_pathkeys entirely.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/relation.h5
-rw-r--r--src/include/optimizer/paths.h5
-rw-r--r--src/include/optimizer/planmain.h5
3 files changed, 8 insertions, 7 deletions
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index 88e535dc9b9..3b23bfbeb4e 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.117 2005/07/23 21:05:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.118 2005/08/27 22:13:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -101,6 +101,9 @@ typedef struct PlannerInfo
List *query_pathkeys; /* desired pathkeys for query_planner(),
* and actual pathkeys afterwards */
+ List *group_pathkeys; /* groupClause pathkeys, if any */
+ List *sort_pathkeys; /* sortClause pathkeys, if any */
+
double tuple_fraction; /* tuple_fraction passed to query_planner */
bool hasJoinRTEs; /* true if any RTEs are RTE_JOIN kind */
diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h
index 8f26c8e8f0d..7c8108b000a 100644
--- a/src/include/optimizer/paths.h
+++ b/src/include/optimizer/paths.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/optimizer/paths.h,v 1.86 2005/07/28 20:26:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/paths.h,v 1.87 2005/08/27 22:13:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -102,9 +102,6 @@ extern void generate_implied_equalities(PlannerInfo *root);
extern List *canonicalize_pathkeys(PlannerInfo *root, List *pathkeys);
extern PathKeysComparison compare_pathkeys(List *keys1, List *keys2);
extern bool pathkeys_contained_in(List *keys1, List *keys2);
-extern PathKeysComparison compare_noncanonical_pathkeys(List *keys1,
- List *keys2);
-extern bool noncanonical_pathkeys_contained_in(List *keys1, List *keys2);
extern Path *get_cheapest_path_for_pathkeys(List *paths, List *pathkeys,
CostSelector cost_criterion);
extern Path *get_cheapest_fractional_path_for_pathkeys(List *paths,
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
index 474a14da9a0..652431b894f 100644
--- a/src/include/optimizer/planmain.h
+++ b/src/include/optimizer/planmain.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/optimizer/planmain.h,v 1.87 2005/08/18 17:51:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/planmain.h,v 1.88 2005/08/27 22:13:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,7 +22,8 @@
*/
extern void query_planner(PlannerInfo *root, List *tlist,
double tuple_fraction,
- Path **cheapest_path, Path **sorted_path);
+ Path **cheapest_path, Path **sorted_path,
+ double *num_groups);
/*
* prototypes for plan/planagg.c