Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 7712B1337B43 for ; Tue, 1 Feb 2011 16:32:55 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 11367-05 for ; Tue, 1 Feb 2011 20:32:49 +0000 (UTC) Received: from amadensor.com (amadensor.com [200.46.208.228]) by mail.postgresql.org (Postfix) with ESMTP id 4E61E1337B67 for ; Tue, 1 Feb 2011 16:32:48 -0400 (AST) Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by amadensor.com (Postfix) with ESMTP id C123018A68D1 for ; Tue, 1 Feb 2011 20:32:46 +0000 (UTC) Received: from amadensor.com ([200.46.208.228]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 88472-03; Tue, 1 Feb 2011 20:32:35 +0000 (UTC) Received: from [192.168.40.129] (unknown [76.76.81.70]) by amadensor.com (Postfix) with ESMTPA id 7C9F818A6880; Tue, 1 Feb 2011 20:32:34 +0000 (UTC) Message-ID: <4D486D9A.9040404@amadensor.com> Date: Tue, 01 Feb 2011 13:31:22 -0700 From: Grant Johnson User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20101227 Icedove/3.0.11 MIME-Version: 1.0 To: pgsql-performance@postgresql.org CC: Jon Nelson Subject: Re: Any experience using "shake" defragmenter? References: <4D45C607.4070101@vmsinfo.com> <4D485DFC.4090808@2ndquadrant.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/10 X-Sequence-Number: 42148 > Instead of something like 'shake' (which more or less works, even > though it doesn't use fallocate and friends) I frequently use either > CLUSTER (which is what Greg Smith is suggesting) or a series of ALTER > TABLE ... ALTER COLUMN... which rewrites the table. With PG 9 perhaps > VACUUM FULL is more appropriate. Of course, the advice regarding > using 'shake' (or any other defragmenter) on a "live" postgresql data > directory is excellent - the potential for causing damage if the > database is active during that time is very high. > > I agree that unless it makes sure there are no open file handles before moving the file, there is a high chance of corrupting data, and if it does check, there is little chance it will do anything useful on a live DB, since it will skip every open file. Does vacuum full rewrite the whole table, or only the blocks with free space? If it only rewrites the blocks with free space, the only solution may be exclusive table lock, alter table to new name, create old table name as select * from new table name. I also like the cluster idea, but I am not sure if it rewrites everything, or just the blocks that have out of order rows, in which case, it would not work well the second time.