Re: table clustering brings joy - Mailing list pgsql-general

From Greg Stark
Subject Re: table clustering brings joy
Date
Msg-id 87fyt9tkih.fsf@stark.xeocode.com
Whole thread Raw
In response to table clustering brings joy  (Kevin Murphy <murphy@genome.chop.edu>)
Responses Re: table clustering brings joy  (Kevin Murphy <murphy@genome.chop.edu>)
List pgsql-general
Kevin Murphy <murphy@genome.chop.edu> writes:

> This is just an FYI for other people out there with large tables: table
> clustering sped up my queries from 10-100 times, which I am very happy about.
> I'm posting this in case it's ever useful to anybody.  If someone reading this
> feels that I did something wrong, let me know.

One thing you should realize is that cluster effectively removes all dead
tuples from the table. If you had lots of dead tuples that could have been
slowing things down.

Vacuum only marks dead tuples for reuse. If you're not running vacuum often
enough or you've done big batch updates then you may have accumulated lots of
dead tuples and then your vacuum analyze doesn't actually remove them from the
table.

Moreover, if the tables are undergoing updates or deletes then you should
expect to always have some steady state level of dead tuples in the table. Any
tests conducted immediately after a "vacuum full" or "cluster" won't include
that factor.

All that said clustering is indeed often quite effective. Especially if it
makes an index scan efficient enough to win over sequential scans you can see
some huge effects. It's most useful for tables that aren't undergoing lots of
updates and don't need to be reclustered often.

--
greg

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: trigger question
Next
From: Matthew Terenzio
Date:
Subject: syntax error foreign key