Re: Any experience using "shake" defragmenter?

From: Grant Johnson <grant(at)amadensor(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Cc: Jon Nelson <jnelson+pgsql(at)jamponi(dot)net>
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-02-01 20:31:22
Message-ID: 4D486D9A.9040404@amadensor.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


> 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.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Haas 2011-02-01 22:33:11 Re: Any experience using "shake" defragmenter?
Previous Message Bruce Momjian 2011-02-01 20:24:05 Re: Questions on query planner, join types, and work_mem