|
15 | 15 | *
|
16 | 16 | *
|
17 | 17 | * 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 $ |
19 | 19 | *
|
20 | 20 | *-------------------------------------------------------------------------
|
21 | 21 | */
|
@@ -144,10 +144,13 @@ eqsel(Oid opid,
|
144 | 144 | selec=1.0-commonfrac-nullfrac;
|
145 | 145 | if (selec>commonfrac)
|
146 | 146 | 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! |
149 | 151 | */
|
150 |
| -selec *=0.5; |
| 152 | +if (typid!=BOOLOID) |
| 153 | +selec *=0.5; |
151 | 154 | }
|
152 | 155 | }
|
153 | 156 | else
|
@@ -310,20 +313,20 @@ scalarltsel(Oid opid,
|
310 | 313 | /* If we trusted the stats fully, we could return a small or
|
311 | 314 | * large selec depending on which side of the single data point
|
312 | 315 | * 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... |
314 | 317 | */
|
315 | 318 | *result=DEFAULT_INEQ_SEL;
|
316 |
| -} |
317 |
| -elseif (val <=low||val >=high) |
| 319 | +} |
| 320 | +elseif (val<low||val>high) |
318 | 321 | {
|
319 | 322 | /* If given value is outside the statistical range, return a
|
320 | 323 | * small or large value; but not 0.0/1.0 since there is a chance
|
321 | 324 | * the stats are out of date.
|
322 | 325 | */
|
323 | 326 | if (flag&SEL_RIGHT)
|
324 |
| -*result= (val <=low) ?0.01 :0.99; |
| 327 | +*result= (val<low) ?0.001 :0.999; |
325 | 328 | else
|
326 |
| -*result= (val <=low) ?0.99 :0.01; |
| 329 | +*result= (val<low) ?0.999 :0.001; |
327 | 330 | }
|
328 | 331 | else
|
329 | 332 | {
|
|