Re: What are the benefits of using a clustered index?

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: What are the benefits of using a clustered index?
Дата
Msg-id 49BF4A6B.8080804@postnewspapers.com.au
обсуждение исходный текст
Ответ на What are the benefits of using a clustered index?  (Mike Christensen <imaudi@comcast.net>)
Список pgsql-general
Mike Christensen wrote:

>  However, if the query
> planner can't assume the data is in a certain order on disk, what's the
> point of having this at all?

One benefit is that it reduces the number of pages that must be read
from disk to retrieve all tuples that have a particular value for the
indexed field. Because the tuples tend to be clustered by (in your case)
recipeid, you'll normally have quite a few relevant tuples on a page and
won't have as much uninteresting and irrelevent data getting read in
along with what you actually want. That'll also improve efficiency of
memory/cache use.

I think it also helps keep the index smaller, since it doesn't need to
refer to as many pages for a given value of interest.

If you set a non-default FILLFACTOR on the table (and proably index) Pg
will leave gaps in the table and I think it will try to insert tuples to
maintain clustering order for smaller indexes and faster index scans.
The downside is that there are holes in the table that may slow down a
sequential scan somewhat.

--
Craig Ringer

В списке pgsql-general по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: Postgres 8.2.x support on Windows 2008
Следующее
От: Stuart Bishop
Дата:
Сообщение: Re: postgreSQL & amazon ec2 cloud