Further tweaking of indexscan cost estimates.
This commit is contained in:
parent
5db0ef84e6
commit
9c38a8d296
@ -42,7 +42,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.55 2000/03/30 00:53:29 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.56 2000/04/09 04:31:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -262,9 +262,12 @@ cost_index(Path *path, Query *root,
|
||||
* effect. Would be nice to do better someday.
|
||||
*/
|
||||
|
||||
tuples_fetched = ceil(indexSelectivity * baserel->tuples);
|
||||
tuples_fetched = indexSelectivity * baserel->tuples;
|
||||
/* Don't believe estimates less than 1... */
|
||||
if (tuples_fetched < 1.0)
|
||||
tuples_fetched = 1.0;
|
||||
|
||||
if (tuples_fetched > 0 && baserel->pages > 0)
|
||||
if (baserel->pages > 0)
|
||||
pages_fetched = ceil(baserel->pages *
|
||||
log(tuples_fetched / baserel->pages + 1.0));
|
||||
else
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.62 2000/03/30 00:53:30 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.63 2000/04/09 04:31:37 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -902,10 +902,19 @@ genericcostestimate(Query *root, RelOptInfo *rel,
|
||||
lfirsti(rel->relids));
|
||||
|
||||
/* Estimate the number of index tuples that will be visited */
|
||||
numIndexTuples = ceil(*indexSelectivity * index->tuples);
|
||||
numIndexTuples = *indexSelectivity * index->tuples;
|
||||
|
||||
/* Estimate the number of index pages that will be retrieved */
|
||||
numIndexPages = ceil(*indexSelectivity * index->pages);
|
||||
numIndexPages = *indexSelectivity * index->pages;
|
||||
|
||||
/*
|
||||
* Always estimate at least one tuple and page are touched,
|
||||
* even when indexSelectivity estimate is tiny.
|
||||
*/
|
||||
if (numIndexTuples < 1.0)
|
||||
numIndexTuples = 1.0;
|
||||
if (numIndexPages < 1.0)
|
||||
numIndexPages = 1.0;
|
||||
|
||||
/*
|
||||
* Compute the index access cost.
|
||||
|
Loading…
x
Reference in New Issue
Block a user