Re: Any experience using "shake" defragmenter?

Lists: pgsql-performance
From: Mladen Gogala <mladen(dot)gogala(at)vmsinfo(dot)com>
To: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Any experience using "shake" defragmenter?
Date: 2011-01-30 20:11:51
Message-ID: 4D45C607.4070101@vmsinfo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

Did anyone try using "shake" while the cluster is active? Any problems
with corruption or data loss? I ran the thing on my home directory and
nothing was broken. I didn't develop any performance test, so cannot
vouch for the effectiveness of the procedure. Did anyone play with that?
Any positive or negative things to say about shake?

--
Mladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
www.vmsinfo.com


From: "Mark Felder" <feld(at)feld(dot)me>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-01-30 21:31:26
Message-ID: op.vp44qo0134t2sn@me-pc.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

On Sun, 30 Jan 2011 14:11:51 -0600, Mladen Gogala
<mladen(dot)gogala(at)vmsinfo(dot)com> wrote:

> Did anyone try using "shake" while the cluster is active? Any problems
> with corruption or data loss? I ran the thing on my home directory and
> nothing was broken. I didn't develop any performance test, so cannot
> vouch for the effectiveness of the procedure. Did anyone play with that?
> Any positive or negative things to say about shake?
>

Why do you feel the need to defrag your *nix box?

Regards,

Mark


From: Marcin Mirosław <marcin(at)mejor(dot)pl>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-01-30 22:27:16
Message-ID: 4D45E5C4.1090203@mejor.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

W dniu 2011-01-30 22:31, Mark Felder pisze:
> Why do you feel the need to defrag your *nix box?

I'm guessing, maybe he used filefrag and saw >30000 extents? :)
Next question will be "which fs do you use?" and then flame will start:(
Regards


From: Mladen Gogala <mladen(dot)gogala(at)vmsinfo(dot)com>
To: Marcin Mirosław <marcin(at)mejor(dot)pl>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-01-31 04:33:02
Message-ID: 4D463B7E.9070304@vmsinfo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

Marcin Mirosław wrote:
> W dniu 2011-01-30 22:31, Mark Felder pisze:
>
>> Why do you feel the need to defrag your *nix box?
>>
>
> I'm guessing, maybe he used filefrag and saw >30000 extents? :)
> Next question will be "which fs do you use?" and then flame will start:(
> Regards
>
>
With all due respect, I don't want to start a fruitless flame war. I am
asking those who have used it about their experiences with the product.
Let's leave discussion of my motivation for some other time. I guess
it's all about my unhappy childhood. If you have used the defragmenter,
I'd be grateful for your experience.

--
Mladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
www.vmsinfo.com


From: Mladen Gogala <mladen(dot)gogala(at)vmsinfo(dot)com>
To: Mark Felder <feld(at)feld(dot)me>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-01-31 04:38:38
Message-ID: 4D463CCE.90806@vmsinfo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

Mark Felder wrote:
> Why do you feel the need to defrag your *nix box?
>
>
>
Let's stick to the original question and leave my motivation for some
other time. Have you used the product? If you have, I'd be happy to hear
about your experience with it.

--
Mladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
www.vmsinfo.com


From: Lew <noone(at)lewscanon(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-01-31 12:28:39
Message-ID: ii69sr$foj$1@news.albasani.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

On 01/30/2011 11:38 PM, Mladen Gogala wrote:
> Mark Felder wrote:
>> Why do you feel the need to defrag your *nix box?
>>
>>
> Let's stick to the original question and leave my motivation for some other
> time. Have you used the product? If you have, I'd be happy to hear about your
> experience with it.

That seems a little harsh. You post to a discussion group but want to
suppress discussion?

Maybe that works with paid tech-support staff, but here ...

--
Lew
Ceci n'est pas une fenêtre.
.___________.
|###] | [###|
|##/ | *\##|
|#/ * | \#|
|#----|----#|
|| | * ||
|o * | o|
|_____|_____|
|===========|


From: Florian Weimer <fweimer(at)bfk(dot)de>
To: "Mark Felder" <feld(at)feld(dot)me>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-01-31 16:44:07
Message-ID: 82k4hl81m0.fsf@mid.bfk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

* Mark Felder:

> Why do you feel the need to defrag your *nix box?

Some file systems (such as XFS) read the whole extent list into RAM
when a file is opened. When the extend list is long due to
fragmentation, this can take a *long* time (in the order of minutes
with multi-gigabyte Oracle Berkeley DB files). This phenomenon is
less pronounced with PostgreSQL because it splits large relations into
one-gigabyte chunks, and it writes the files sequentally. But a small
effect is probably still there.

--
Florian Weimer <fweimer(at)bfk(dot)de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstraße 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99


From: Florian Weimer <fweimer(at)bfk(dot)de>
To: mladen(dot)gogala(at)vmsinfo(dot)com
Cc: "pgsql-performance\(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-01-31 16:49:53
Message-ID: 82ei7t81ce.fsf@mid.bfk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

* Mladen Gogala:

> Did anyone try using "shake" while the cluster is active?

As far as I can tell, it's totally unsafe.

--
Florian Weimer <fweimer(at)bfk(dot)de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstraße 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99


From: Lew <noone(at)lewscanon(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-01-31 23:41:26
Message-ID: ii7ha6$aqv$1@news.albasani.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

Please reply to the list with list business.

On 01/31/2011 03:22 PM, Mladen Gogala wrote:
> On 1/31/2011 7:28 AM, Lew wrote:
>> That seems a little harsh.
> Oh? How so?
>> You post to a discussion group but want to
>> suppress discussion?
>
> No, I just want to stick to the subject. My motivation for doing so, my
> unhappy childhood or somebody's need for attention are not too important. If
> you have had any experience with the product, I'd be extremely keen to learn
> about it and grateful to you for sharing it. If not, then....well, I'll
> explain my reasoning some other time. I have better things to do right now.
>
>> Maybe that works with paid tech-support staff, but here ...
>>
> Things have lived up to my expectation. Basically, the only people who replied
> are those who have no experience with the product but apparently do have an
> irresistible urge to discuss something that I am not particularly interested
> in discussing.
>

I'm so very, very sorry that we insist on having a discussion instead of
adhering to your ukase.

Perhaps your dictatorial attitude discourages people from responding? I mean,
Mark Felder asked a perfectly reasonable question and now you're all snarky.
Well, a big "Harrumph!" to that!

I wish you the best of luck. You'll need it with that attitude.

--
Lew
Ceci n'est pas une fenêtre.
.___________.
|###] | [###|
|##/ | *\##|
|#/ * | \#|
|#----|----#|
|| | * ||
|o * | o|
|_____|_____|
|===========|


From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: mladen(dot)gogala(at)vmsinfo(dot)com
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-02-01 19:24:44
Message-ID: 4D485DFC.4090808@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

Mladen Gogala wrote:
> Did anyone try using "shake" while the cluster is active? Any problems
> with corruption or data loss? I ran the thing on my home directory and
> nothing was broken. I didn't develop any performance test, so cannot
> vouch for the effectiveness of the procedure. Did anyone play with
> that? Any positive or negative things to say about shake?
>

Shake works by allocating a new file the size of the original, in what
is presumed to be then be unfragmented space. It copies the original
over to this new space and then gets rid of the original. That
procedure will cause database corruption if the server happens to access
the file it's moving while it's in the middle of doing so. If the
database isn't running, though, it is probably fine.

On ext3 you can measure whether it was useful or not by taking the
filesystem off-line and running fsck before/after using it. Look for
percentages given for "non-contiguous files" and directories. If those
were low to begin with, little reason to run the utility. If they're
high, running shake should bring them down afterwards if it's doing its
job right.

On a PostgreSQL database system, you can get the same basic effect while
leaving the server up--but just with the table locked--using CLUSTER.
And that will clean up a bunch of other potential messes inside the
database that shake can't touch. I just do that instead if I'm worried
a particular table has become fragmented on disk.

--
Greg Smith 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books


From: Jon Nelson <jnelson+pgsql(at)jamponi(dot)net>
To: Greg Smith <greg(at)2ndquadrant(dot)com>
Cc: mladen(dot)gogala(at)vmsinfo(dot)com, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-02-01 19:38:13
Message-ID: AANLkTimE_qe1YD+t==xton3SdfXcOYL1Pk6kb0su2_Dh@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

On Tue, Feb 1, 2011 at 1:24 PM, Greg Smith <greg(at)2ndquadrant(dot)com> wrote:
> Mladen Gogala wrote:
>>
>> Did anyone try using "shake" while the cluster is active? Any problems
>> with corruption or data loss? I ran the thing on my home directory and
>> nothing was broken. I didn't develop any performance test, so cannot vouch
>> for the effectiveness of the procedure. Did anyone play with that? Any
>> positive or negative things to say about shake?
>>
>
> Shake works by allocating a new file the size of the original, in what is
> presumed to be then be unfragmented space.  It copies the original over to
> this new space and then gets rid of the original.  That procedure will cause
> database corruption if the server happens to access the file it's moving
> while it's in the middle of doing so.  If the database isn't running,
> though, it is probably fine.
>
> On ext3 you can measure whether it was useful or not by taking the
> filesystem off-line and running fsck before/after using it.  Look for
> percentages given for "non-contiguous files" and directories.  If those were
> low to begin with, little reason to run the utility.  If they're high,
> running shake should bring them down afterwards if it's doing its job right.
>
> On a PostgreSQL database system, you can get the same basic effect while
> leaving the server up--but just with the table locked--using CLUSTER.  And
> that will clean up a bunch of other potential messes inside the database
> that shake can't touch.  I just do that instead if I'm worried a particular
> table has become fragmented on disk.

One thing to note is that, in my experiments, ext4 handles large files
(such as the 1GiB files postgresql uses for large relations) in a
*vastly* improved manner over ext3. This is due to the use of
extents. I found that, in some cases, heavily fragmented files under
ext3 could not be effectively defragmented - and yes, I tried shake
and some others (including one I wrote which *does* use fallocate /
fallocate_posix). There was improvement, but by far the biggest
improvement was switching to ext4.

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.

--
Jon


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


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Grant Johnson <grant(at)amadensor(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org, Jon Nelson <jnelson+pgsql(at)jamponi(dot)net>
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-02-01 22:33:11
Message-ID: AANLkTikJeisVNDvqdNitvA5L+sps8ateO=sj6BGhX30C@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

On Tue, Feb 1, 2011 at 3:31 PM, Grant Johnson <grant(at)amadensor(dot)com> wrote:
> Does vacuum full rewrite the whole table, or only the blocks with free
> space?

The whole table.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Any experience using "shake" defragmenter?
Date: 2011-02-01 23:50:12
Message-ID: 4D489C34.6040904@catalyst.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

On 31/01/11 17:38, Mladen Gogala wrote:
> Mark Felder wrote:
>> Why do you feel the need to defrag your *nix box?
>>
>>
> Let's stick to the original question and leave my motivation for some
> other time. Have you used the product? If you have, I'd be happy to
> hear about your experience with it.
>
>

Mladen sometimes asking about the motivation behind a question brings to
light new information that makes the original question no longer
relevant. In this case it might bring to light a better solution than
"Shake", or else methods for determining if fragmentation is harmful or
not.

I don't believe people are asking in order to either flame you or insult
your intelligence, but there is genuine interest in why you are wanting
to defrag. There is a lot of expertise on this list - indulging a little
curiosity will only help you get better value for your questions.

Cheers

Mark

P.s: I'm curious too :-)