Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id EC47EB5DC0E for ; Thu, 26 May 2011 17:37:55 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 94774-04 for ; Thu, 26 May 2011 20:37:48 +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 9771AB5DC0D for ; Thu, 26 May 2011 17:37:48 -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 p4QKbj01028974; Thu, 26 May 2011 16:37:46 -0400 (EDT) To: Robert Haas cc: Greg Stark , Florian Helmberger , pgsql-hackers@postgresql.org, Alvaro Herrera Subject: Re: [ADMIN] pg_class reltuples/relpages not updated by autovacuum/vacuum In-reply-to: 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> Comments: In-reply-to Robert Haas message dated "Thu, 26 May 2011 13:08:46 -0400" Date: Thu, 26 May 2011 16:37:45 -0400 Message-ID: <28973.1306442265@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/1375 X-Sequence-Number: 188409 Robert Haas writes: > On Thu, May 26, 2011 at 12:23 PM, Tom Lane wrote: >>> Another thought: Couldn't relation_needs_vacanalyze() just scale up >>> reltuples by the ratio of the current number of pages in the relation >>> to relpages, just as the query planner does? >> Hmm ... that would fix Florian's immediate issue, and it does seem like >> a good change on its own merits.  But it does nothing for the problem >> that we're failing to put the best available information into pg_class. >> >> Possibly we could compromise on doing just that much in the back >> branches, and the larger change for 9.1? > Do you think we need to worry about the extra overhead of determining > the current size of every relation as we sweep through pg_class? It's > not a lot, but OTOH I think we'd be doing it once a minute... not sure > what would happen if there were tons of tables. Ugh ... that is a mighty good point, since the RelationGetNumberOfBlocks call would have to happen for each table, even the ones we then decide not to vacuum. We've already seen people complain about the cost of the AV launcher once they have a lot of databases, and this would probably increase it quite a bit. > Going back to your thought upthread, I think we should really consider > replacing reltuples with reltupledensity at some point. I continue to > be afraid that using a decaying average in this case is going to end > up overweighting the values from some portion of the table that's > getting scanned repeatedly, at the expense of other portions of the > table that are not getting scanned at all. Changing the representation of the information would change that issue not in the slightest. The fundamental point here is that we have new, possibly partial, information which we ought to somehow merge with the old, also possibly partial, information. Storing the data a little bit differently doesn't magically eliminate that issue. regards, tom lane