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 1esgf4-0008N0-Kj for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Mar 2018 03:19:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1esgf3-0008UH-BW for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Mar 2018 03:19:37 +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.89) (envelope-from ) id 1esgf3-0008U7-4Q for pgsql-hackers@lists.postgresql.org; Mon, 05 Mar 2018 03:19:37 +0000 Received: from d.mail.sonic.net ([64.142.111.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1esgeu-00049s-EJ for pgsql-hackers@lists.postgresql.org; Mon, 05 Mar 2018 03:19:36 +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 w253JJ6D029609 (version=TLSv1.2 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Sun, 4 Mar 2018 19:19:19 -0800 Date: Sun, 4 Mar 2018 19:19:18 -0800 From: David Gould To: Jeff Janes Cc: PostgreSQL Hackers , Alina Alexeeva , Ullas Lakkur Raghavendra Subject: Re: [patch] BUG #15005: ANALYZE can make pg_class.reltuples inaccurate. Message-ID: <20180304191918.39e95382@engels> In-Reply-To: References: <20180117164916.3fdcf2e9@engels> 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: UmFuZG9tSVbtSv1j76Ex0usovrQB3D2do+ExxjUNnQw3NzOEi4eFBsAQUDJRDzIyzt57hSJnEtGEW1u9fbjNFsB2H36V1/Yy X-Sonic-ID: C;hqog/iMg6BG7KyAFsE207w== M;+ABO/iMg6BG7KyAFsE207w== 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 Sun, 4 Mar 2018 07:49:46 -0800 Jeff Janes wrote: > I don't see how it could have caused the problem in the first place. In > your demonstration case, you had to turn off autovac in order to get it to > happen, and then when autovac is turned back on, it is all primed for an > autovac to launch, go through, touch almost all of the pages, and fix it > for you. How did your original table get into a state where this wouldn't > happen? One more way for this to happen, vacuum was including the dead tuples in the estimate in addition to the live tuples. This is a separate bug that tends to aggravate the one I'm trying to fix. See the thread re BUG #15005 at: https://www.postgresql.org/message-id/16db4468-edfa-830a-f921-39a50498e77e%402ndquadrant.com > It seems to me that VACUUM and ANALYZE somewhat disagree on what exactly > reltuples means. VACUUM seems to be thinking that > > reltuples = live + dead > > while ANALYZE apparently believes that > > reltuples = live There is a patch for this one from Tomas Vondra/Tom Lane that I hope it will land in the next set of releases. -dg -- David Gould daveg@sonic.net If simplicity worked, the world would be overrun with insects.