Unix Technical Forum

"vacuum" and "cluster"

This is a discussion on "vacuum" and "cluster" within the Pgsql General forums, part of the PostgreSQL category; --> Hello, Does running "cluster" remove the need to run "vacuum"? I get a feeling that since cluster is already ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 04:09 PM
Jimmy Choi
 
Posts: n/a
Default "vacuum" and "cluster"

Hello,

Does running "cluster" remove the need to run "vacuum"?

I get a feeling that since cluster is already physically reordering
the rows, it may as well remove the dead rows... no?

My second question is, if vacuum is still needed, does it matter
whether I run vacuum first or cluster first?

Here's our current weekly db maintenance routine:

1. vacuum full
2. cluster
3. reindex
4. analyze

Thanks,
Jimmy

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 04:09 PM
Craig Ringer
 
Posts: n/a
Default Re: "vacuum" and "cluster"

Jimmy Choi wrote:
> Hello,
>
> Does running "cluster" remove the need to run "vacuum"?


My understanding is that `CLUSTER' creates a new table file, then swaps
it out for the old one.

http://www.postgresql.org/docs/8.3/s...l-cluster.html

" During the cluster operation, a temporary copy of the table is created
that contains the table data in the index order. Temporary copies of
each index on the table are created as well. Therefore, you need free
space on disk at least equal to the sum of the table size and the index
sizes. "

It's not stated explicitly, but I'm pretty sure discussion here has
mentioned that too. Given that, VACUUM FULL on a just-CLUSTERed table
should be redundant.

The easy way to be sure is to use ANALYZE VERBOSE to examine the dead
row counts etc before and after each operation.

--
Craig Ringer

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 04:09 PM
Alvaro Herrera
 
Posts: n/a
Default Re: "vacuum" and "cluster"

Craig Ringer escribió:

> It's not stated explicitly, but I'm pretty sure discussion here has
> mentioned that too. Given that, VACUUM FULL on a just-CLUSTERed table
> should be redundant.


It is, and a REINDEX is redundant too because CLUSTER does it
internally.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 04:09 PM
Jimmy Choi
 
Posts: n/a
Default Re: "vacuum" and "cluster"

Presumably, even if CLUSTER does reindexing internally, it only does
that for the index used for clustering. Since REINDEX includes all
indices, CLUSTER cannot truly replace REINDEX. Correct?

Jimmy

On Wed, Apr 16, 2008 at 12:06 PM, Alvaro Herrera
<alvherre@commandprompt.com> wrote:
> Craig Ringer escribió:
>
>
> > It's not stated explicitly, but I'm pretty sure discussion here has
> > mentioned that too. Given that, VACUUM FULL on a just-CLUSTERed table
> > should be redundant.

>
> It is, and a REINDEX is redundant too because CLUSTER does it
> internally.
>
> --
> Alvaro Herrera http://www.CommandPrompt.com/
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-17-2008, 04:09 PM
Alvaro Herrera
 
Posts: n/a
Default Re: "vacuum" and "cluster"

Jimmy Choi escribió:
> Presumably, even if CLUSTER does reindexing internally, it only does
> that for the index used for clustering. Since REINDEX includes all
> indices, CLUSTER cannot truly replace REINDEX. Correct?


No. Cluster rewrites all indexes (otherwise their entries would end up
pointing to incorrect places in the heap.)

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:31 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com