Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdeee4e1

Browse files
committed
Make eqsel produce better results for boolean columns,
and make scalarltsel a little more forgiving at the boundaries of theknown range of a column value.
1 parent9c80cce commitdeee4e1

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

‎src/backend/utils/adt/selfuncs.c

Lines changed: 12 additions & 9 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.55 2000/02/15 20:49:21 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.56 2000/02/16 00:59:27 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -144,10 +144,13 @@ eqsel(Oid opid,
144144
selec=1.0-commonfrac-nullfrac;
145145
if (selec>commonfrac)
146146
selec=commonfrac;
147-
/* and in fact it's probably less, so apply a fudge
148-
* factor.
147+
/* and in fact it's probably less, so we should apply
148+
* a fudge factor. The only case where we don't is
149+
* for a boolean column, where indeed we have estimated
150+
* the less-common value's frequency exactly!
149151
*/
150-
selec *=0.5;
152+
if (typid!=BOOLOID)
153+
selec *=0.5;
151154
}
152155
}
153156
else
@@ -310,20 +313,20 @@ scalarltsel(Oid opid,
310313
/* If we trusted the stats fully, we could return a small or
311314
* large selec depending on which side of the single data point
312315
* the constant is on. But it seems better to assume that the
313-
* stats areout of date and return a default...
316+
* stats arewrong and return a default...
314317
*/
315318
*result=DEFAULT_INEQ_SEL;
316-
}
317-
elseif (val <=low||val >=high)
319+
}
320+
elseif (val<low||val>high)
318321
{
319322
/* If given value is outside the statistical range, return a
320323
* small or large value; but not 0.0/1.0 since there is a chance
321324
* the stats are out of date.
322325
*/
323326
if (flag&SEL_RIGHT)
324-
*result= (val <=low) ?0.01 :0.99;
327+
*result= (val<low) ?0.001 :0.999;
325328
else
326-
*result= (val <=low) ?0.99 :0.01;
329+
*result= (val<low) ?0.999 :0.001;
327330
}
328331
else
329332
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp