Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2D0BF9FC170 for ; Fri, 23 Feb 2007 05:13:38 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 46938-01 for ; Fri, 23 Feb 2007 05:13:33 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) by postgresql.org (Postfix) with ESMTP id 4BC2D9FC03A for ; Fri, 23 Feb 2007 05:13:33 -0400 (AST) Received: from einstein.muc.ecircle.de (einstein.muc.ecircle.de [192.168.1.7]) by mail.ecircle.de (READY) with ESMTP id D6BBC55C00D; Fri, 23 Feb 2007 10:13:31 +0100 (CET) Received: from [192.168.1.91] ([192.168.1.91]) by einstein.muc.ecircle.de with Microsoft SMTPSVC(6.0.3790.1830); Fri, 23 Feb 2007 10:13:31 +0100 Subject: Re: Using the 8.2 autovacuum values with 8.1 From: Csaba Nagy To: Mark Stosberg Cc: postgres performance list In-Reply-To: References: <20070221185544.GX25424@alvh.no-ip.org> <45DCAD50.8080104@zeut.net> Content-Type: text/plain Message-Id: <1172222011.3772.13.camel@coppola.muc.ecircle.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Fri, 23 Feb 2007 10:13:31 +0100 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 23 Feb 2007 09:13:31.0250 (UTC) FILETIME=[E3075520:01C7572A] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.059 tagged_above=0 required=5 tests=AWL, BAYES_50, SPF_PASS X-Spam-Level: X-Archive-Number: 200702/237 X-Sequence-Number: 23291 On Thu, 2007-02-22 at 22:53, Mark Stosberg wrote: > Thanks to everyone for the feedback about vacuuming. It's been very > useful. The pointers to the pgstattuple and Pgfouine tools were also > helpful. > > I'm now considering the following plan for trying Autovacuuming again > with 8.1. I'd like any peer review you have to offer of the following: > > 1. First, I'll move the settings to match the defaults in 8.2. The ones > I noticed in particular were: > > autovacuum_vacuum_threshold changes: 1000 -> 500 > autovacuum_anayze_threshold changes: 500 -> 250 > autovacuum_scale_factor changes: .4 -> .2 > autovacuum_analyze_scale_factor changes .2 -> .1 > > 2. Try the vacuum cost delay feature, starting with a 20ms value: > > autovacuum_vacuum_cost_delay = 20 > > 3. Immediately add a row to pg_autovacuum for a huge logging table that > would be too slow to vacuum usually. We'll still vacuum it once a week > for good measure by cron. > > 4. For good measure, I think I still keep the nightly cron entry that > does a complete vacuum analyze (except for that large table...). > > Seem like a reasonable plan? You likely don't need the nightly full vacuum run... we also do here a nightly vacuum beside autovacuum, but not a full one, only for tables which are big enough that we don't want autovacuum to touch them in high business time but they have enough change that we want a vacuum on them frequent enough. I discover them by checking the stats, for example: SELECT c.relname, c.reltuples::bigint as rowcnt, pg_stat_get_tuples_inserted(c.oid) AS inserted, pg_stat_get_tuples_updated(c.oid) AS updated, pg_stat_get_tuples_deleted(c.oid) AS deleted FROM pg_class c WHERE c.relkind = 'r'::"char" GROUP BY c.oid, c.relname, c.reltuples HAVING pg_stat_get_tuples_updated(c.oid) + pg_stat_get_tuples_deleted(c.oid) > 1000 ORDER BY pg_stat_get_tuples_updated(c.oid) + pg_stat_get_tuples_deleted(c.oid) DESC; The top tables in this list for which the (deleted + updated) / rowcnt is relatively small but still significant need your attention for nightly vacuum... the rest is handled just fine by autovacuum. On the other end of the scale, if you have tables for which the deletion/update rate is way higher then the row count, that's likely a hot-spot table which you probably need extra vacuuming during the day. Cheers, Csaba.