7
7
* Portions Copyright (c) 1994, Regents of the University of California
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.39 2000/01/26 05:57:17 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.40 2000/02/16 01:00:23 tgl Exp $
11
11
*
12
12
* NOTES
13
13
* Eventually, the index information should go through here, too.
@@ -183,6 +183,7 @@ double
183
183
get_attdisbursion (Oid relid ,AttrNumber attnum ,double min_estimate )
184
184
{
185
185
HeapTuple atp ;
186
+ Form_pg_attribute att_tup ;
186
187
double disbursion ;
187
188
int32 ntuples ;
188
189
@@ -197,10 +198,21 @@ get_attdisbursion(Oid relid, AttrNumber attnum, double min_estimate)
197
198
relid ,attnum );
198
199
return min_estimate ;
199
200
}
201
+ att_tup = (Form_pg_attribute )GETSTRUCT (atp );
200
202
201
- disbursion = (( Form_pg_attribute ) GETSTRUCT ( atp )) -> attdisbursion ;
203
+ disbursion = att_tup -> attdisbursion ;
202
204
if (disbursion > 0.0 )
203
- return disbursion ;/* we have a specific estimate */
205
+ return disbursion ;/* we have a specific estimate from VACUUM */
206
+
207
+ /*
208
+ * Special-case boolean columns: the disbursion of a boolean is highly
209
+ * unlikely to be anywhere near 1/numtuples, instead it's probably more
210
+ * like 0.5.
211
+ *
212
+ * Are there any other cases we should wire in special estimates for?
213
+ */
214
+ if (att_tup -> atttypid == BOOLOID )
215
+ return 0.5 ;
204
216
205
217
/*
206
218
* Disbursion is either 0 (no data available) or -1 (disbursion