Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 7C48CB5DBF7 for ; Thu, 26 May 2011 18:24:42 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 15938-05 for ; Thu, 26 May 2011 21:24:35 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id 25773B5D832 for ; Thu, 26 May 2011 18:24:35 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Thu, 26 May 2011 16:24:34 -0500 Message-Id: <4DDE7EB8020000250003DDA8@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Thu, 26 May 2011 16:24:24 -0500 From: "Kevin Grittner" To: "Robert Haas" Cc: "Florian Helmberger" , "Alvaro Herrera" , "Greg Stark" , ,"Tom Lane" Subject: Re: [ADMIN] pg_class reltuples/relpages not updated by autovacuum/vacuum References: <4DD28F73.6010108@25th-floor.com> <25017.1306291669@sss.pgh.pa.us> <4DDCA801.70805@25th-floor.com> <19738.1306338472@sss.pgh.pa.us> <22497.1306341699@sss.pgh.pa.us> <15043.1306423500@sss.pgh.pa.us> <25097.1306426982@sss.pgh.pa.us> <4DDE475B020000250003DD63@gw.wicourts.gov> <4DDE5033020000250003DD71@gw.wicourts.gov> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/1383 X-Sequence-Number: 188417 Robert Haas wrote: > Kevin Grittner wrote: >> By storing the ratio and one count you make changes to the >> other count implied and less visible. It seems more >> understandable and less prone to error (to me, anyway) to keep >> the two "raw" numbers and calculate the ratio -- and when you >> observe a change in one raw number which you believe should force >> an adjustment to the other raw number before its next actual >> value is observed, to comment on why that's a good idea, and do >> the trivial arithmetic at that time. > > Except that's not how it works. At least in the case of ANALYZE, > we *aren't* counting all the tuples in the table. We're selecting > a random sample of pages and inferring a tuple density, which we > then extrapolate to the whole table and store. Then when we pull > it back out of the table, we convert it back to a tuple density. > The real value we are computing and using almost everywhere is > tuple density; storing a total number of tuples in the table > appears to be just confusing the issue. Well, if tuple density is the number which is most heavily used, it might shave a few nanoseconds doing the arithmetic in enough places to justify the change, but I'm skeptical. Basically I'm with Tom on the fact that this change would store neither more nor less information (and for that matter would not really change what information you can easily retrieve); and slightly changing the manner in which it is stored doesn't solve any of the problems you assert that it does. When we prune or vacuum a page, I don't suppose we have enough information about that page's previous state to calculate a tuple count delta, do we? That would allow a far more accurate number to be maintained than anything suggested so far, as long as we tweak autovacuum to count inserts toward the need to vacuum. (It seems to me I saw a post giving some reason that would have benefits anyway.) Except for the full pass during transaction wrap-around protection, where it could just set a new actual count, autovacuum would be skipping pages where the bit is set to indicate that all tuples are visible, right? -Kevin