Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A9BAD64FCDF for ; Fri, 22 Aug 2008 21:41:44 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 92325-07-4 for ; Fri, 22 Aug 2008 21:41:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from oxford.xeocode.com (87-127-95-198.no-dns-yet.enta.net [87.127.95.198]) by postgresql.org (Postfix) with ESMTP id 6233E64FD40 for ; Fri, 22 Aug 2008 21:40:03 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.69) (envelope-from ) id 1KWhAa-0001tS-UV; Sat, 23 Aug 2008 01:39:57 +0100 To: "Bill Moran" Cc: "Fernando Hevia" , Subject: Re: Big delete on big table... now what? In-Reply-To: <20080822184407.37155367.wmoran@collaborativefusion.com> (Bill Moran's message of "Fri\, 22 Aug 2008 18\:44\:07 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.performance" 6652) References: <042c01c90496$ca8725f0$8f01010a@iptel.com.ar> <20080822184407.37155367.wmoran@collaborativefusion.com> From: Gregory Stark Organization: EnterpriseDB Date: Sat, 23 Aug 2008 01:39:56 +0100 Message-ID: <87r68gpns3.fsf@oxford.xeocode.com> MIME-Version: 1.0 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=0.1 tagged_above=0 required=5 tests=RDNS_DYNAMIC=0.1 X-Spam-Level: X-Archive-Number: 200808/289 X-Sequence-Number: 31170 "Bill Moran" writes: > "Fernando Hevia" wrote: >> >> Hi list. >>=20=20 >> I have a table with over 30 million rows. Performance was dropping stead= ily >> so I moved old data not needed online to an historic table. Now the table >> has about 14 million rows. I don't need the disk space returned to the OS >> but I do need to improve performance. Will a plain vacuum do or is a vac= uum >> full necessary? >> =BFWould a vacuum full improve performance at all? > > If you can afford the downtime on that table, cluster would be best. > > If not, do the normal vacuum and analyze. This is unlikely to improve > the performance much (although it may shrink the table _some_) but > regular vacuum will keep performance from getting any worse. Note that CLUSTER requires enough space to store the new and the old copies= of the table simultaneously. That's the main reason for VACUUM FULL to still exist. There is also the option of doing something like (assuming id is already an integer -- ie this doesn't actually change the data): ALTER TABLE x ALTER id TYPE integer USING id; which will rewrite the whole table. This is effectively the same as CLUSTER except it doesn't order the table according to an index. It will still requ= ire enough space to hold two copies of the table but it will be significantly faster. --=20 Gregory Stark EnterpriseDB http://www.enterprisedb.com Ask me about EnterpriseDB's RemoteDBA services!