Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 452149FB250 for ; Sat, 5 May 2007 19:57:35 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 55439-06 for ; Sat, 5 May 2007 19:57:26 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.178]) by postgresql.org (Postfix) with ESMTP id 4BE989FB24D for ; Sat, 5 May 2007 19:57:30 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id a73so982745pye for ; Sat, 05 May 2007 15:57:29 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=rqPSQKmidIyGu4su25/pF9eShzIw5LZKi5n4+LjTTEJATGx2PIVTRpwkQLvwkjRBQQbPdtN7fAhY2LrnvFtpiLE6+WcmHhnoaj4RbmB9P8Zr2VuqfXqeOxfX4fUn4pe/eUkGiz+5s3JATyrfD+t1HZ9MTCVKlcaRMT/gPGrX6m8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=b+YKn+x/04uef0qOU2CZPSfKx1wz8E0scrsRfLUV/zVwkq1AdPgPcou8oLBcnQowXJnNG6gdIPTg6seljx1rKFRi6O0dcBoW3TAKfClN3dJ9kgdxAxdDvv5MlCuQ9EoMW1WC4at7OshDdYTQIBRr5x+HxS4ncaF0dDStMLaHiFU= Received: by 10.35.134.19 with SMTP id l19mr8118042pyn.1178405849057; Sat, 05 May 2007 15:57:29 -0700 (PDT) Received: from ?192.168.1.10? ( [71.116.121.169]) by mx.google.com with ESMTP id y64sm6887613pyg.2007.05.05.15.57.26; Sat, 05 May 2007 15:57:27 -0700 (PDT) Message-ID: <463D0BD5.3010404@gmail.com> Date: Sat, 05 May 2007 15:57:25 -0700 From: Yudhvir Singh Sidhu User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: How to Find Cause of Long Vacuum Times - NOOB Question Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/57 X-Sequence-Number: 24447 I hope someone can help me with this vacuum problem. I can post more info if needed. Versions: Postgresql version 8.09 on FreeBSD 6.1 Situation: huge amounts of adds and deletes daily. Running daily vacuums Problem: Vacuum times jump up from 45 minutes, or 1:30 minutes to 6+ hours overnight, once every 1 to 3 months. Solutions tried: db truncate - brings vacuum times down. Reindexing brings vacuum times down. I know my indexes are getting fragmented and my tables are getting fragmented. I also know that some of my btree indexes are not being used in queries. I also know that using "UNIQUE" in a query makes PG ignore any index. I am looking for the cause of this. Recently I have been looking at EXPLAIN and ANALYZE. 1. Running EXPLAIN on a query tells me how my query SHOULD run and running ANALYZE tells me how it DOES run. Is that correct? 2. If (1) is true, then a difference between the two means my query plan is messed up and running ANALYZE on a table-level will somehow rebuild the plan. Is that correct? 3. If (2) is correct, then running ANALYZE on a nightly basis before running vacuum will keep vacuum times down. Is that correct? Yudhvir Singh