diff options
author | Vadim B. Mikheev <vadim4o@yahoo.com> | 1997-04-09 01:52:04 +0000 |
---|---|---|
committer | Vadim B. Mikheev <vadim4o@yahoo.com> | 1997-04-09 01:52:04 +0000 |
commit | fa2629b7eaa46d1295843f091c45e107b19cadd7 (patch) | |
tree | 0e3db6196da983726fee64c238ed24fadd567699 /src | |
parent | b30aa6ecb89f79871625cd7bd1d8767029e1e02a (diff) | |
download | postgresql-fa2629b7eaa46d1295843f091c45e107b19cadd7.tar.gz postgresql-fa2629b7eaa46d1295843f091c45e107b19cadd7.zip |
Fix (hack) IndexSelectivity():
use sum(npages)/((nkeys == 1) ? 1 : nkeys + 1) as expected index page
estimation for multi-key quals - instead of sum(npages).
In old code npages for x > 10 and x < 20 is twice as for x > 10 - cool ?
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/util/plancat.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index 7a108578ed1..eda5830d2cf 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.4 1997/03/12 21:06:14 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.5 1997/04/09 01:52:04 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -564,9 +564,17 @@ IndexSelectivity(Oid indexrelid, (char *) constFlags[n], (char *) nIndexKeys, (char *) indexrelid); +#if 0 +/* + * So cool guys! Npages for x > 10 and x < 20 is twice as + * npages for x > 10! - vadim 04/09/97 + */ npages += PointerIsValid(amopnpages) ? *amopnpages : 0.0; if ((i = npages) < npages) /* ceil(npages)? */ npages += 1.0; +#endif + npages += PointerIsValid(amopnpages) ? *amopnpages : 0.0; + amopselect = (float64) fmgr(amop->amopselect, (char *) operatorObjectIds[n], (char *) indrelid, @@ -577,7 +585,13 @@ IndexSelectivity(Oid indexrelid, (char *) indexrelid); select *= PointerIsValid(amopselect) ? *amopselect : 1.0; } - *idxPages = npages; + /* + * Estimation of npages below is hack of course, but it's + * better than it was before. - vadim 04/09/97 + */ + if ( nIndexKeys > 1 ) + npages = npages / (1.0 + nIndexKeys); + *idxPages = ceil ((double)(npages/nIndexKeys)); *idxSelec = select; } |