Skip to content

Commit b71761d

Browse files
committed
Reduce eqsel()'s fudge-factor for estimating the frequency of values
other than the most common value in a column. We had had 0.5, make it 0.1 to make it more likely that an indexscan will be chosen. Really need better statistics instead, but this should stem the bleeding meanwhile ...
1 parent be6e771 commit b71761d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/backend/utils/adt/selfuncs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.65 2000/04/16 04:41:02 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.66 2000/05/26 17:19:15 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -55,6 +55,9 @@
5555
/* default selectivity estimate for pattern-match operators such as LIKE */
5656
#define DEFAULT_MATCH_SEL 0.01
5757

58+
/* "fudge factor" for estimating frequency of not-most-common values */
59+
#define NOT_MOST_COMMON_RATIO 0.1
60+
5861
static bool convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue,
5962
Datum lobound, Datum hibound, Oid boundstypid,
6063
double *scaledlobound, double *scaledhibound);
@@ -190,7 +193,7 @@ eqsel(Oid opid,
190193
* exactly!
191194
*/
192195
if (typid != BOOLOID)
193-
selec *= 0.5;
196+
selec *= NOT_MOST_COMMON_RATIO;
194197
}
195198
}
196199
else
@@ -209,7 +212,7 @@ eqsel(Oid opid,
209212
* and in fact it's probably less, so apply a fudge
210213
* factor.
211214
*/
212-
selec *= 0.5;
215+
selec *= NOT_MOST_COMMON_RATIO;
213216
}
214217

215218
/* result should be in range, but make sure... */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy