Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id CE1EF19CDE12 for ; Mon, 5 Dec 2011 14:36:49 -0400 (AST) Received: from gwmta.wicourts.gov ([165.219.244.99] helo=gw.wicourts.gov) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RXdPE-00032F-Rk for pgsql-performance@postgresql.org; Mon, 05 Dec 2011 18:36:50 +0000 Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Mon, 05 Dec 2011 12:36:36 -0600 Message-Id: <4EDCBAD2020000250004384F@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Mon, 05 Dec 2011 12:36:34 -0600 From: "Kevin Grittner" To: "=?ISO-8859-15?Q?Ernesto=20Qui=F1ones?=" , Subject: Re: Question about VACUUM References: <4ED9F32A02000025000437EC@gw.wicourts.gov> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Pg-Spam-Score: -5.4 (-----) X-Archive-Number: 201112/39 X-Sequence-Number: 45838 Ernesto Qui=F1ones wrote: =20 I understand the impulse to run autovacuum less frequently or less aggressively. When we first started running PostgreSQL the default configuration was very cautious. A lot of bloat would accumulate before it kicked in, at which point there was a noticeable performance hit, as it worked though a large number of dead pages.=20 The first thing I did was to make it run less often, which only made things worse. The numbers we settled on through testing as optimal for us are very close to current default values (for recent major releases). =20 Not only do queries run more quickly between autovacuum runs, because there is less dead space to wade through to get the current tuples, but the autovacuum runs just don=27t have the same degree of impact -- presumably because they find less to do. Some small, frequently updated tables when from having hundreds of pages down to one or two. =20 > autovacuum_analyze_scale_factor 0,5 > autovacuum_analyze_threshold 50000 =20 We use 0.10 + 10 in production. Defaults are now 0.10 + 50. That=27s the portion of the table plus a number of rows. Analyze just does a random sample from the table; it doesn=27t pass the whole table. =20 > autovacuum_vacuum_scale_factor 0,5 > autovacuum_vacuum_threshold 50000 =20 We use 0.20 + 10 in production. Defaults are now 0.20 + 50. Again, a proportion of the table (in this case what is expected to have become unusable dead space) plus a number of unusable dead tuples. =20 > autovacuum_naptime 1h =20 A one-page table could easily bloat to hundreds (or thousands) of pages within an hour. You will wonder where all your CPU time is going because it will constantly be scanning the same (cached) pages to find the one version of the row which matters. I recommend 1min. =20 > vacuum_cost_delay 1s =20 A vacuum run will never get much done at that rate. I recommend 10ms. =20 > vacuum_cost_limit 200 =20 We=27ve boosted this to 600. Once you=27re in a =22steady state=22, this = is the setting you might want to adjust up or down as needed to make cleanup aggressive enough without putting a noticeable dent in performance while it is running. =20 On 8.3 I believe you still need to worry about the fsm settings.=20 Run your regular database vacuum with the VERBOSE option, and check what the last few lines say. If you don=27t have enough memory set aside to track free space, no vacuum regimen will prevent bloat. =20 -Kevin