|
42 | 42 | * Portions Copyright (c) 1994, Regents of the University of California
|
43 | 43 | *
|
44 | 44 | * IDENTIFICATION
|
45 |
| - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.96 2002/12/14 00:17:55 tgl Exp $ |
| 45 | + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.97 2002/12/26 23:38:42 tgl Exp $ |
46 | 46 | *
|
47 | 47 | *-------------------------------------------------------------------------
|
48 | 48 | */
|
@@ -1164,6 +1164,16 @@ estimate_hash_bucketsize(Query *root, Var *var)
|
1164 | 1164 | if (avgfreq>0.0&&mcvfreq>avgfreq)
|
1165 | 1165 | estfract *=mcvfreq /avgfreq;
|
1166 | 1166 |
|
| 1167 | +/* |
| 1168 | + * Clamp bucketsize to sane range (the above adjustment could easily |
| 1169 | + * produce an out-of-range result). We set the lower bound a little |
| 1170 | + * above zero, since zero isn't a very sane result. |
| 1171 | + */ |
| 1172 | +if (estfract<1.0e-6) |
| 1173 | +estfract=1.0e-6; |
| 1174 | +elseif (estfract>1.0) |
| 1175 | +estfract=1.0; |
| 1176 | + |
1167 | 1177 | ReleaseSysCache(tuple);
|
1168 | 1178 |
|
1169 | 1179 | return (Selectivity)estfract;
|
|