Re: Clustered indexes - When to use them? - Mailing list pgsql-general

From MaXX
Subject Re: Clustered indexes - When to use them?
Date
Msg-id dkb5ao$25p3$1@talisker.lacave.net
Whole thread Raw
In response to Clustered indexes - When to use them?  (MaXX <bs139412@skynet.be>)
Responses Re: Clustered indexes - When to use them?  (Scott Marlowe <smarlowe@g2switchworks.com>)
Re: Clustered indexes - When to use them?  ("Jim C. Nasby" <jnasby@pervasive.com>)
List pgsql-general
Ok thank you,
so I can consider using clustered indexes when I need to 'reorder' random
data to improve the speed of a particular query...

In simple words:
Clustered indexes are like the alphabetical index in a book, where term are
randomly distibuted in the book and regular indexes are more like the table
of content...
Right?

Thanks again,
MaXX

Jim C. Nasby wrote:
> The key expense in doing an index scan is the amount of randomness
> involved in reading the base table. If a table is in the same order as
> the index then reading the base table will be very fast. If the table is
> in a completely random order compared to an index (it's correlation is
> low), then an index scan becomes very expensive because every row you
> read out of the index means seeking to a random page in the table.
>
> So, if you do a lot of querying on the table that would work best with
> an index scan, it's probably worth it to cluster on that index.
>
> Note that I'm talking about index *scans* here, where you're pulling a
> decent number of rows.
>
> There's some other considerations as well, but this is probably the
> biggest one.
>

--
MaXX


pgsql-general by date:

Previous
From: Alex Turner
Date:
Subject: Re: SQL injection
Next
From: Robert Treat
Date:
Subject: Re: looking for multi-language app example using postgresql