Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVj8a-0004fp-A5 for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Aug 2016 17:42:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bVj8Z-0006rT-Sv for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Aug 2016 17:42:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bVj7C-0004e3-PQ for pgsql-hackers@postgresql.org; Fri, 05 Aug 2016 17:40:58 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bVj79-0007lr-Rc for pgsql-hackers@postgresql.org; Fri, 05 Aug 2016 17:40:58 +0000 Received: from localhost ([127.0.0.1]:49210 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtp (Exim 4.84 (FreeBSD)) (envelope-from ) id 1bVj78-00092f-1j; Fri, 05 Aug 2016 17:40:54 +0000 From: Andrew Gierth To: Tom Lane Cc: pgsql-hackers@postgresql.org, Andreas Joseph Krogh Subject: Re: Bogus ANALYZE results for an otherwise-unique column with many nulls In-Reply-To: <4174.1470407261@sss.pgh.pa.us> (Tom Lane's message of "Fri, 05 Aug 2016 10:27:41 -0400") Message-ID: <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> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (berkeley-unix) Date: Fri, 05 Aug 2016 18:40:53 +0100 MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -3.1 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org >>>>> "Tom" == Tom Lane 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