Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 6959D6356D3 for ; Mon, 13 Sep 2010 20:48:24 -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 99265-07 for ; Mon, 13 Sep 2010 23:48:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from glacier.frostconsultingllc.com (glacier.frostconsultingllc.com [69.36.227.170]) by mail.postgresql.org (Postfix) with ESMTP id 1743163387E for ; Mon, 13 Sep 2010 20:47:47 -0300 (ADT) Received: from dsl081-245-111.sfo1.dsl.speakeasy.net ([64.81.245.111] helo=Sidney-Stratton.local) by glacier.frostconsultingllc.com with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.69) (envelope-from ) id 1OvIkP-0005dc-H8 for pgsql-performance@postgresql.org; Mon, 13 Sep 2010 16:47:44 -0700 Message-ID: <4C8EB813.6070204@agliodbs.com> Date: Mon, 13 Sep 2010 16:47:31 -0700 From: Josh Berkus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20090223 Thunderbird/3.0b2 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Where does data in pg_stat_user_tables come from? References: <4C8EAE5E.70201@agliodbs.com> <1284421288.28610.501.camel@jd-desktop.unknown.charter.com> In-Reply-To: <1284421288.28610.501.camel@jd-desktop.unknown.charter.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201009/65 X-Sequence-Number: 40268 On 9/13/10 4:41 PM, Joshua D. Drake wrote: > On Mon, 2010-09-13 at 16:06 -0700, Josh Berkus wrote: >> All, >> >> I've been looking at pg_stat_user_tables (in 8.3, because of a project I >> have), and it appears that autovacuum, and only autovaccum, updates the >> data for this view. This means that one can never have data in >> pg_stat_user_tables which is completely up-to-date, and if autovacuum is >> off, the view is useless. > > As I recall its kept in shared_buffers (in some kind of counter) and > updated only when it is requested or when autovacuum fires. This was > done because we used to write stats every 500ms and it was a bottleneck. > (IIRC) Yes, looks like it only gets updated on SELECT or on autovacuum. Thing is, a full VACUUM ANALYZE on the database, or even just ANALYZE, should update some of the counters. And currently it doesnt, resulting in pg_class.reltuples often being far more up to date than pg_stat_user_tables.n_live_tup. And frankly, no way to reconcile those two stats. -- -- Josh Berkus PostgreSQL Experts Inc. http://www.pgexperts.com