1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-27 00:12:01 +03:00

Further work on making use of new statistics in planner. Adjust APIs

of costsize.c routines to pass Query root, so that costsize can figure
more things out by itself and not be so dependent on its callers to tell
it everything it needs to know.  Use selectivity of hash or merge clause
to estimate number of tuples processed internally in these joins
(this is more useful than it would've been before, since eqjoinsel is
somewhat more accurate than before).
This commit is contained in:
Tom Lane
2001-06-05 05:26:05 +00:00
parent 28d2420eef
commit 7c579fa12d
20 changed files with 337 additions and 195 deletions

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: cost.h,v 1.39 2001/05/07 00:43:26 tgl Exp $
* $Id: cost.h,v 1.40 2001/06/05 05:26:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -52,20 +52,27 @@ extern bool enable_nestloop;
extern bool enable_mergejoin;
extern bool enable_hashjoin;
extern void cost_seqscan(Path *path, RelOptInfo *baserel);
extern void cost_seqscan(Path *path, Query *root,
RelOptInfo *baserel);
extern void cost_index(Path *path, Query *root,
RelOptInfo *baserel, IndexOptInfo *index,
List *indexQuals, bool is_injoin);
extern void cost_tidscan(Path *path, RelOptInfo *baserel, List *tideval);
extern void cost_sort(Path *path, List *pathkeys, double tuples, int width);
extern void cost_nestloop(Path *path, Path *outer_path, Path *inner_path,
List *restrictlist);
extern void cost_mergejoin(Path *path, Path *outer_path, Path *inner_path,
List *restrictlist,
List *outersortkeys, List *innersortkeys);
extern void cost_hashjoin(Path *path, Path *outer_path, Path *inner_path,
List *restrictlist, Selectivity innerbucketsize);
extern Selectivity estimate_hash_bucketsize(Query *root, Var *var);
RelOptInfo *baserel, IndexOptInfo *index,
List *indexQuals, bool is_injoin);
extern void cost_tidscan(Path *path, Query *root,
RelOptInfo *baserel, List *tideval);
extern void cost_sort(Path *path, Query *root,
List *pathkeys, double tuples, int width);
extern void cost_nestloop(Path *path, Query *root,
Path *outer_path, Path *inner_path,
List *restrictlist);
extern void cost_mergejoin(Path *path, Query *root,
Path *outer_path, Path *inner_path,
List *restrictlist,
List *mergeclauses,
List *outersortkeys, List *innersortkeys);
extern void cost_hashjoin(Path *path, Query *root,
Path *outer_path, Path *inner_path,
List *restrictlist,
List *hashclauses);
extern Cost cost_qual_eval(List *quals);
extern void set_baserel_size_estimates(Query *root, RelOptInfo *rel);
extern void set_joinrel_size_estimates(Query *root, RelOptInfo *rel,
@@ -84,5 +91,8 @@ extern Selectivity restrictlist_selectivity(Query *root,
extern Selectivity clauselist_selectivity(Query *root,
List *clauses,
int varRelid);
extern Selectivity clause_selectivity(Query *root,
Node *clause,
int varRelid);
#endif /* COST_H */

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pathnode.h,v 1.37 2001/05/20 20:28:20 tgl Exp $
* $Id: pathnode.h,v 1.38 2001/06/05 05:26:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,40 +26,43 @@ extern int compare_fractional_path_costs(Path *path1, Path *path2,
extern void set_cheapest(RelOptInfo *parent_rel);
extern void add_path(RelOptInfo *parent_rel, Path *new_path);
extern Path *create_seqscan_path(RelOptInfo *rel);
extern Path *create_seqscan_path(Query *root, RelOptInfo *rel);
extern IndexPath *create_index_path(Query *root, RelOptInfo *rel,
IndexOptInfo *index,
List *restriction_clauses,
List *pathkeys,
ScanDirection indexscandir);
extern TidPath *create_tidscan_path(RelOptInfo *rel, List *tideval);
extern TidPath *create_tidscan_path(Query *root, RelOptInfo *rel,
List *tideval);
extern AppendPath *create_append_path(RelOptInfo *rel, List *subpaths);
extern Path *create_subqueryscan_path(RelOptInfo *rel);
extern NestPath *create_nestloop_path(RelOptInfo *joinrel,
JoinType jointype,
Path *outer_path,
Path *inner_path,
List *restrict_clauses,
List *pathkeys);
extern NestPath *create_nestloop_path(Query *root,
RelOptInfo *joinrel,
JoinType jointype,
Path *outer_path,
Path *inner_path,
List *restrict_clauses,
List *pathkeys);
extern MergePath *create_mergejoin_path(RelOptInfo *joinrel,
JoinType jointype,
Path *outer_path,
Path *inner_path,
List *restrict_clauses,
List *pathkeys,
List *mergeclauses,
List *outersortkeys,
List *innersortkeys);
extern MergePath *create_mergejoin_path(Query *root,
RelOptInfo *joinrel,
JoinType jointype,
Path *outer_path,
Path *inner_path,
List *restrict_clauses,
List *pathkeys,
List *mergeclauses,
List *outersortkeys,
List *innersortkeys);
extern HashPath *create_hashjoin_path(RelOptInfo *joinrel,
JoinType jointype,
Path *outer_path,
Path *inner_path,
List *restrict_clauses,
List *hashclauses,
Selectivity innerbucketsize);
extern HashPath *create_hashjoin_path(Query *root,
RelOptInfo *joinrel,
JoinType jointype,
Path *outer_path,
Path *inner_path,
List *restrict_clauses,
List *hashclauses);
/*
* prototypes for relnode.c

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: planmain.h,v 1.50 2001/03/22 04:00:55 momjian Exp $
* $Id: planmain.h,v 1.51 2001/06/05 05:26:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -29,9 +29,10 @@ extern Plan *create_plan(Query *root, Path *best_path);
extern SubqueryScan *make_subqueryscan(List *qptlist, List *qpqual,
Index scanrelid, Plan *subplan);
extern Append *make_append(List *appendplans, bool isTarget, List *tlist);
extern Sort *make_sort(List *tlist, Plan *lefttree, int keycount);
extern Sort *make_sort_from_pathkeys(List *tlist, Plan *lefttree,
List *pathkeys);
extern Sort *make_sort(Query *root, List *tlist,
Plan *lefttree, int keycount);
extern Sort *make_sort_from_pathkeys(Query *root, List *tlist,
Plan *lefttree, List *pathkeys);
extern Agg *make_agg(List *tlist, List *qual, Plan *lefttree);
extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp,
AttrNumber *grpColIdx, Plan *lefttree);

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: planner.h,v 1.19 2001/01/24 19:43:26 momjian Exp $
* $Id: planner.h,v 1.20 2001/06/05 05:26:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,6 +21,7 @@
extern Plan *planner(Query *parse);
extern Plan *subquery_planner(Query *parse, double tuple_fraction);
extern Plan *make_sortplan(List *tlist, Plan *plannode, List *sortcls);
extern Plan *make_sortplan(Query *parse, List *tlist,
Plan *plannode, List *sortcls);
#endif /* PLANNER_H */