Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id BEF23632817; Tue, 23 Mar 2010 18:42:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 96559-06; Tue, 23 Mar 2010 21:41:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yw0-f184.google.com (mail-yw0-f184.google.com [209.85.211.184]) by mail.postgresql.org (Postfix) with ESMTP id 1C3BE63271B; Tue, 23 Mar 2010 18:41:50 -0300 (ADT) Received: by ywh14 with SMTP id 14so1026093ywh.15 for ; Tue, 23 Mar 2010 14:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=V6JlsbaZ/71UZnO/u9mJf2PZIvY/liA1AKBFwgfBnuc=; b=pYlaAVlthZkAzxJK898hQkUFYFNw2KMJXiXRQ7g7ae728zZog5eK1lD/y94c/oyKNf 3NL+O9fIpr0K/9tF6X7OTfGPbnA91nvbVX1/jFNwRJBfVrl4Gp0o5uu1jNqhm/rC4iXk XwfF6tMdAzZIAdAF9oPJUZANt1SxN0+j51RlU= 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=qqfMTwnpqNFGwi53myyzTe1X98D6LpQxt/78yXoV3WFNFOqeXDe1pRXpNs3ouBpVN6 6Igro3G2h+U27TwnqOIE84XHlm7WHBygwgbvaj8kR+ehe35j2sHd8+ZUJp6mJ5d7qApc THrd7n3yhq9QVp3bE9Hmv5fIvDvrXZYKd0Cf0= MIME-Version: 1.0 Received: by 10.150.170.11 with SMTP id s11mr8422670ybe.241.1269380508761; Tue, 23 Mar 2010 14:41:48 -0700 (PDT) In-Reply-To: References: Date: Tue, 23 Mar 2010 15:41:48 -0600 Message-ID: Subject: Re: tuning auto vacuum for highly active tables From: Scott Marlowe To: Bhella Paramjeet-PFCW67 Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org 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=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/174 X-Sequence-Number: 33973 On Tue, Mar 23, 2010 at 2:54 PM, Bhella Paramjeet-PFCW67 wrote: > Hi All, > > > > We have a postgres database in which couple of tables get bloated due to > heavy inserts and deletes. Auto vacuum is running. My question is =A0how = can I > make auto vacuum more aggressive? I am thinking of enabling > autovacuum_vacuum_cost_delay and autovacuum_vacuum_cost_limit parameters. > Can anyone suggest how to calculate the appropriate values for these > parameters and if there are any side effects of enabling these parameters= . > =A0Any help will be highly appreciated. OK, autovacuum runs x number of threads, and these threads can have their IO impact limited by cost delay and cost limit. Your first choice is based a lot on your db needs. If you have a lot of large tables that all need to be vacuumed a lot, then you might want to first increase the number of threads before making any of them more aggressive. Then you might want to make the vacuums more aggressive by lower cost_delay down from 20 to 10 or 5 or so milliseconds. On our servers we run 6 threads with a cost_delay of 3 or 4 milliseconds, and autovacuum keeps up without getting in the way. We have a decent DAS array, so we can handle a lot of vacuum threads running at once before they become an issue. The smaller your disk set, the less you can throw vacuum at it and not expect it to mess up the rest of the app. It's all a trade off, but if you don't have more than a disk or two to throw at your db don't expect vacuum to keep up with really heavy activity without impacting your system's performance.