Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erxN8-0000Gg-QS for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Mar 2018 02:58:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1erxN7-0001rY-DW for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Mar 2018 02:58:05 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erxN7-0001rP-3E for pgsql-hackers@lists.postgresql.org; Sat, 03 Mar 2018 02:58:05 +0000 Received: from d.mail.sonic.net ([64.142.111.50]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erxN1-0002qH-8i for pgsql-hackers@lists.postgresql.org; Sat, 03 Mar 2018 02:58:02 +0000 Received: from engels (162-236-13-58.lightspeed.sntcca.sbcglobal.net [162.236.13.58]) (authenticated bits=0) by d.mail.sonic.net (8.15.1/8.15.1) with ESMTPSA id w232vrxb024125 (version=TLSv1.2 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 2 Mar 2018 18:57:53 -0800 Date: Fri, 2 Mar 2018 18:57:52 -0800 From: David Gould To: Tom Lane Cc: Alexander Kuzmenkov , pgsql-hackers@lists.postgresql.org, Alina Alexeeva , Ullas Lakkur Raghavendra Subject: Re: [patch] BUG #15005: ANALYZE can make pg_class.reltuples inaccurate. Message-ID: <20180302185752.46b82671@engels> In-Reply-To: <32701.1520029049@sss.pgh.pa.us> References: <20180117164916.3fdcf2e9@engels> <20180228192337.67cc3f99@engels> <4988c54a-1709-a978-9a43-65f8a1e09e94@postgrespro.ru> <18522.1519916974@sss.pgh.pa.us> <1386effe-0e6d-fd5a-6f0d-f294e4ef2dda@postgrespro.ru> <3240.1519948160@sss.pgh.pa.us> <101dd073-1cb7-b471-7eeb-aa9ee928a1c9@postgrespro.ru> <20180302140037.00af305d@engels> <32701.1520029049@sss.pgh.pa.us> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Sonic-CAuth: UmFuZG9tSVbHSntCG/TrJeEObXGv9pMth/MUzDfZMhOT000Ax/Mdl5esJi4Kkyb+g0Ty1ngUTvX1677H3pEbVUM87jZzkEbC X-Sonic-ID: C;noqzqo4e6BG1giAFsE207w== M;Hj7fqo4e6BG1giAFsE207w== X-Spam-Flag: No X-Sonic-Spam-Details: 0.0/5.0 by cerberusd List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, 02 Mar 2018 17:17:29 -0500 Tom Lane wrote: > But by the same token, analyze only looked at 0.0006 of the pages. It's > nice that for you, that's enough to get a robust estimate of the density > everywhere; but I have a nasty feeling that that won't hold good for > everybody. My grasp of statistics is somewhat weak, so please inform me if I've got this wrong, but every time I've looked into it I've found that one can get pretty good accuracy and confidence with fairly small samples. Typically 1000 samples will serve no matter the population size if the desired margin of error is 5%. Even with 99% confidence and a 1% margin of error it takes less than 20,000 samples. See the table at: http://www.research-advisors.com/tools/SampleSize.htm Since we have by default 30000 sample pages and since ANALYZE takes some trouble to get a random sample I think we really can rely on the results of extrapolating reltuples from analyze. -dg -- David Gould daveg@sonic.net If simplicity worked, the world would be overrun with insects.