Re: About when we should setup index?

From: Francisco Reyes <lists(at)stringsutils(dot)com>
To: emilu(at)encs(dot)concordia(dot)ca
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: About when we should setup index?
Date: 2006-03-21 00:19:45
Message-ID: cone.1142900385.10665.59709.5001@35st-server.simplicato.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Emi Lu writes:

One more thing to consider. If you have a column with lots of repeated
values and a handfull of selective values, you could use a partial index.

http://www.postgresql.org/docs/8.0/interactive/indexes-partial.html

For example imagine you have an accounts table like
Accounts
account_id integer
name varchar
special_cust boolean

Where special_cust are customers that subscribe to some premiun and
expensive service.. but there are very few customers that do... you could do
an index like:

CREATE INDEX accuonts_special_cust_idx ON accounts (special_cust)
WHERE special_cust;

In that case if you wanted to see a list of premiun accounts, that index
should bring those records quickly.

See the link above for examples and links to a couple of papers explaining
why/when you want to use a partial index. In particular the document "The
case for partial indexes" , pages 3 and up.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Murali K. Maddali 2006-03-21 00:22:32 xml output
Previous Message Tom Lane 2006-03-20 23:18:30 Re: What's a good default encoding?