mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-11 19:07:33 +08:00
Fix mergejoin cost estimation so that we consider the statistical ranges of
the two join variables at both ends: not only trailing rows that need not be scanned because there cannot be a match on the other side, but initial rows that will be scanned without possibly having a match. This allows a more realistic estimate of startup cost to be made, per recent pgsql-performance discussion. In passing, fix a couple of bugs that had crept into mergejoinscansel: it was not quite up to speed for the task of estimating descending-order scans, which is a new requirement in 8.3.
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.150 2007/11/15 22:25:17 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.151 2007/12/08 21:05:11 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -993,8 +993,10 @@ typedef struct MergeScanSelCache
|
||||
int strategy; /* sort direction (ASC or DESC) */
|
||||
bool nulls_first; /* do NULLs come before normal values? */
|
||||
/* Results */
|
||||
Selectivity leftscansel; /* scan fraction for clause left side */
|
||||
Selectivity rightscansel; /* scan fraction for clause right side */
|
||||
Selectivity leftstartsel; /* first-join fraction for clause left side */
|
||||
Selectivity leftendsel; /* last-join fraction for clause left side */
|
||||
Selectivity rightstartsel; /* first-join fraction for clause right side */
|
||||
Selectivity rightendsel; /* last-join fraction for clause right side */
|
||||
} MergeScanSelCache;
|
||||
|
||||
/*
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/utils/selfuncs.h,v 1.41 2007/11/07 22:37:24 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/utils/selfuncs.h,v 1.42 2007/12/08 21:05:11 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -161,8 +161,8 @@ extern Selectivity rowcomparesel(PlannerInfo *root,
|
||||
|
||||
extern void mergejoinscansel(PlannerInfo *root, Node *clause,
|
||||
Oid opfamily, int strategy, bool nulls_first,
|
||||
Selectivity *leftscan,
|
||||
Selectivity *rightscan);
|
||||
Selectivity *leftstart, Selectivity *leftend,
|
||||
Selectivity *rightstart, Selectivity *rightend);
|
||||
|
||||
extern double estimate_num_groups(PlannerInfo *root, List *groupExprs,
|
||||
double input_rows);
|
||||
|
||||
Reference in New Issue
Block a user