pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Cc: Andreas Joseph Krogh <andreas@visena.com>
Subject: Re: Bogus ANALYZE results for an otherwise-unique column with many nulls
Date: Fri, 05 Aug 2016 18:40:53 +0100
Message-ID: <87oa57dsnn.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <4174.1470407261@sss.pgh.pa.us>
References: <16143.1470350371@sss.pgh.pa.us>
	<871t23fwgb.fsf@news-spur.riddles.org.uk>
	<87wpjvecwz.fsf@news-spur.riddles.org.uk>
	<4174.1470407261@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:

 Tom> Also, the way that the value is calculated in the
 Tom> samples-not-all-distinct case corresponds to the way I have it in
 Tom> 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 very arbitrary 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)


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (12+ messages)  latest in thread

Message-ID: <87oa57dsnn.fsf@news-spur.riddles.org.uk>
Permalink:  ../87oa57dsnn.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87oa57dsnn.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, tgl@sss.pgh.pa.us, andreas@visena.com
  Subject: Re: Bogus ANALYZE results for an otherwise-unique column with many nulls
  In-Reply-To: <87oa57dsnn.fsf@news-spur.riddles.org.uk>
  References: <16143.1470350371@sss.pgh.pa.us> <871t23fwgb.fsf@news-spur.riddles.org.uk> <87wpjvecwz.fsf@news-spur.riddles.org.uk> <4174.1470407261@sss.pgh.pa.us> <87oa57dsnn.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox