Skip to content

Commit 68be513

Browse files
committed
If we don't have any stats for a boolean column, assume
the disbursion is 0.5, not something small.
1 parent deee4e1 commit 68be513

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/backend/utils/cache/lsyscache.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* 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 $
1111
*
1212
* NOTES
1313
* Eventually, the index information should go through here, too.
@@ -183,6 +183,7 @@ double
183183
get_attdisbursion(Oid relid, AttrNumber attnum, double min_estimate)
184184
{
185185
HeapTuple atp;
186+
Form_pg_attribute att_tup;
186187
double disbursion;
187188
int32 ntuples;
188189

@@ -197,10 +198,21 @@ get_attdisbursion(Oid relid, AttrNumber attnum, double min_estimate)
197198
relid, attnum);
198199
return min_estimate;
199200
}
201+
att_tup = (Form_pg_attribute) GETSTRUCT(atp);
200202

201-
disbursion = ((Form_pg_attribute) GETSTRUCT(atp))->attdisbursion;
203+
disbursion = att_tup->attdisbursion;
202204
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;
204216

205217
/*
206218
* Disbursion is either 0 (no data available) or -1 (disbursion

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