Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 4C0B6B5DC36 for ; Wed, 25 May 2011 14:16:08 -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 18234-08 for ; Wed, 25 May 2011 17:16:00 +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 86ACEB5DBF8 for ; Wed, 25 May 2011 14:16:00 -0300 (ADT) Received: by ywe9 with SMTP id 9so2947339ywe.19 for ; Wed, 25 May 2011 10:16:00 -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=QVjqnrbIjq6I3Qvk0IBS+je9JiOiYzxvY82xVlGjTv4=; b=O+BCMJXqjwlAznVJLVtwUltWbRXMSH1Eg3oJaYow82noAZS1DUtacyRomcRPtFxJ0n WiVvW2k7Hg6HHIJEcp1JMaBxZmOkN5Mva4ogN6Q1GWhA9gwIUqvyk1CAPzIxP9htvHp/ W6yatMXRbWscyvwACss/xZLoIXd9S1Jn2+NF0= 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=US8oijibgyPn8eCm0JbIbRgCCZIouks0mtch/ElSmwVsQHKZQ7tnKq3iFveGFNtSjR fI8X5wpYfT5cmCepiE5QZrTjZ/Op/rtQIfWUF0KwNJ/TszP6Iuoey7+SSa8AGvhCVRQh v17NXRGZyIpszd35NCRY0uiDpg9nC5JbsEfq8= MIME-Version: 1.0 Received: by 10.236.77.193 with SMTP id d41mr6832138yhe.206.1306343760126; Wed, 25 May 2011 10:16:00 -0700 (PDT) Received: by 10.236.105.180 with HTTP; Wed, 25 May 2011 10:15:59 -0700 (PDT) In-Reply-To: <22926.1306343067@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> <22926.1306343067@sss.pgh.pa.us> Date: Wed, 25 May 2011 13:15:59 -0400 Message-ID: Subject: Re: [ADMIN] pg_class reltuples/relpages not updated by autovacuum/vacuum From: Robert Haas To: Tom Lane Cc: 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=0.002 tagged_above=-5 required=5 tests=FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201105/1288 X-Sequence-Number: 188322 On Wed, May 25, 2011 at 1:04 PM, Tom Lane wrote: > [ shrug... ] =A0When you don't have complete information, it's *always* > the case that you will sometimes make a mistake. =A0That's not > justification for paralysis, especially not when the existing code is > demonstrably broken. > > What occurs to me after thinking a bit more is that the existing tuple > density is likely to be only an estimate, too (one coming from the last > ANALYZE, which could very well have scanned even less of the table than > VACUUM did). =A0So what I now think is that both VACUUM and ANALYZE ought > to use a calculation of the above form to arrive at a new value for > pg_class.reltuples. =A0In both cases it would be pretty easy to track the > number of pages we looked at while counting tuples, so the same raw > information is available. > >> I am wondering, though, why we're not just inserting a special-purpose >> hack for TOAST tables. > > Because the problem is not specific to TOAST tables. =A0As things > currently stand, we will accept the word of an ANALYZE as gospel even if > it scanned 1% of the table, and completely ignore the results from a > VACUUM even if it scanned 99% of the table. =A0This is not sane. I agree that if VACUUM scanned 99% of the table, it's probably fine to use its numbers. It's also fine to use the numbers from ANALYZE, because those pages are chosen randomly. What bothers me is the idea of using a small *non-random* sample, and I'm not sure that incorporating possibly-bogus results slowly is any better than incorporating them quickly. --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company