1
0
mirror of https://github.com/postgres/postgres.git synced 2026-01-13 12:22:55 +03:00

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.
This commit is contained in:
Tom Lane
2002-11-19 23:22:00 +00:00
parent 54cb1db6cf
commit b60be3f2f8
11 changed files with 454 additions and 75 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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);