Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 05963B5DC13 for ; Thu, 26 May 2011 18:50:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 61205-02 for ; Thu, 26 May 2011 21:50:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 649C9B5DBF9 for ; Thu, 26 May 2011 18:50:05 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p4QLo08d009008; Thu, 26 May 2011 17:50:01 -0400 (EDT) To: "Kevin Grittner" cc: "Robert Haas" , "Florian Helmberger" , "Alvaro Herrera" , "Greg Stark" , pgsql-hackers@postgresql.org Subject: Re: [ADMIN] pg_class reltuples/relpages not updated by autovacuum/vacuum In-reply-to: <4DDE7EB8020000250003DDA8@gw.wicourts.gov> 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> <4DDE7EB8020000250003DDA8@gw.wicourts.gov> Comments: In-reply-to "Kevin Grittner" message dated "Thu, 26 May 2011 16:24:24 -0500" Date: Thu, 26 May 2011 17:50:00 -0400 Message-ID: <9007.1306446600@sss.pgh.pa.us> From: Tom Lane 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/1385 X-Sequence-Number: 188419 "Kevin Grittner" writes: > 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. Well, that was the other direction that was suggested upthread: stop relying on reltuples at all, but use the stats collector's counts. That might be a good solution in the long run, but there are some issues: 1. It's not clear how using a current count, as opposed to time-of-last-vacuum count, would affect the behavior of the autovacuum control logic. At first glance I think it would break it, since the basic logic there is "how much of the table changed since it was last vacuumed?". Even if the equations could be modified to still work, I remember enough feedback control theory from undergrad EE to think that this is something to be seriously scared of tweaking without extensive testing. IMO it is far more risky than what Robert is worried about. 2. You still have the problem that we're exposing inaccurate (or at least less accurate than they could be) counts to the planner and to onlooker clients. We could change the planner to also depend on the stats collector instead of reltuples, but at that point you just removed the option for people to turn off the stats collector. The implications for plan stability might be unpleasant, too. So that's not a direction I want to go without a significant amount of work and testing. regards, tom lane