Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id BF089B5DBE6 for ; Thu, 26 May 2011 12:56:07 -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 77024-07 for ; Thu, 26 May 2011 15:55:59 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yw0-f46.google.com (mail-yw0-f46.google.com [209.85.213.46]) by mail.postgresql.org (Postfix) with ESMTP id 71D43B5DBE0 for ; Thu, 26 May 2011 12:55:59 -0300 (ADT) Received: by ywe9 with SMTP id 9so361878ywe.19 for ; Thu, 26 May 2011 08:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=JyaLA77URStzrQy0DqSxtSbpk0fIJLm3TX4swCGCpHw=; b=scT3fwBW+q7m9RG9m6szR2JipGAiOmQF0ze+Bp2yzJv+EV7ix1bxw3Ln6+EPGvbj3O aJGLxYGgw+OhHGxqrmlNxr6MNJ8cF92Sjy3h+/wE8oQo/l+UDphWNimRV7RBLe3ryamh MS4pzJuD5cTIdTnLZGugcjrRFimxC9Ms8sWtE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=U9S6R37zye/uiYDofIvxdcSil0dftj4OZNoji9PczKcT9cLqbG8eQZK88jRXq/E9Ji xSO1B2E5YqqcSrmx/ocmiap30rG9dyEN9ci0HdOeKBNXbAfD7mwRfo9tyS84HU0XY5UH YmODIQPQoVvrMKrctCr0Eh0GsMQSN3OmLEXjc= MIME-Version: 1.0 Received: by 10.236.156.202 with SMTP id m50mr1311251yhk.407.1306425358744; Thu, 26 May 2011 08:55:58 -0700 (PDT) Received: by 10.236.63.209 with HTTP; Thu, 26 May 2011 08:55:58 -0700 (PDT) In-Reply-To: <15043.1306423500@sss.pgh.pa.us> 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> Date: Thu, 26 May 2011 11:55:58 -0400 Message-ID: Subject: Re: [ADMIN] pg_class reltuples/relpages not updated by autovacuum/vacuum From: Robert Haas To: Tom Lane Cc: Greg Stark , Florian Helmberger , pgsql-hackers@postgresql.org, Alvaro Herrera Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201105/1354 X-Sequence-Number: 188388 On Thu, May 26, 2011 at 11:25 AM, Tom Lane wrote: > I'm still of the opinion that an incremental estimation process like > the above is a lot saner than what we're doing now, snarky Dilbert > references notwithstanding. =A0The only thing that seems worthy of debate > from here is whether we should trust ANALYZE's estimates a bit more than > VACUUM's estimates, on the grounds that the former are more likely to be > from a random subset of pages. =A0We could implement that by applying a > fudge factor when folding a VACUUM estimate into the moving average (ie, > multiply its reliability by something less than one). =A0I don't have any > principled suggestion for just what the fudge factor ought to be, except > that I don't think "zero" is the best value, which AFAICT is what Robert > is arguing. =A0I think Greg's argument shows that "one" is the right valu= e > when dealing with an ANALYZE estimate, if you believe that ANALYZE saw a > random set of pages ... but using that for VACUUM does seem > overoptimistic. The problem is that it's quite difficult to predict the relative frequency of full-relation-vacuum, vacuum-with-skips, and ANALYZE operations on the table will be. It matters how fast the table is being inserted into vs. updated/deleted; and it also matters how fast the table is being updated compared with the system's rate of XID consumption. So in general it seems hard to say, well, we know this number might drift off course a little bit, but there will be a freezing vacuum or analyze or something coming along soon enough to fix the problem. There might be, but it's difficult to be sure. My argument isn't so much that using a non-zero value here is guaranteed to have bad effects, but that we really have no idea what will work out well in practice, and therefore it seems dangerous to whack the behavior around ... especially in stable branches. If we changed this in 9.1, and that's the last time we ever get a complaint about it, problem solved. But I would feel bad if we changed this in the back-branches and then found that, while solving this particular problem, we had created others. It also seems likely that the replacement problems would be more subtle and more difficult to diagnose, because they'd depend in a very complicated way on the workload, and having, say, the latest table contents would not necessarily enable us to reproduce the problem. I would feel a lot better about something that is deterministic, like, I dunno, if VACUUM visits more than 25% of the table, we use its estimate. And we always use ANALYZE's estimate. Or something. 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? --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company