Re: Bogus ANALYZE results for an otherwise-unique column with many nulls - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: Bogus ANALYZE results for an otherwise-unique column with many nulls
Date
Msg-id 87oa57dsnn.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: Bogus ANALYZE results for an otherwise-unique column with many nulls  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Bogus ANALYZE results for an otherwise-unique column with many nulls  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
Tom> Also, the way that the value is calculated in theTom> samples-not-all-distinct case corresponds to the way I have
itinTom> the patch.
 

Ahh, gotcha.  You're referring to this:
       /*        * If we estimated the number of distinct values at more than 10% of        * the total row count (a
veryarbitrary limit), then assume that        * stadistinct should scale with the row count rather than be a fixed
 * value.        */       if (stats->stadistinct > 0.1 * totalrows)           stats->stadistinct = -(stats->stadistinct
/totalrows);
 

where "totalrows" includes nulls obviously. So this expects negative
stadistinct to be scaled by the total table size, and the all-distinct
case should do the same.

Objection withdrawn.

-- 
Andrew (irc:RhodiumToad)



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Re: [sqlsmith] FailedAssertion("!(k == indices_count)", File: "tsvector_op.c", Line: 511)
Next
From: Claudio Freire
Date:
Subject: Re: Heap WARM Tuples - Design Draft