Re: Index Question - Mailing list pgsql-general

From Tom Lane
Subject Re: Index Question
Date
Msg-id 5343.1255964088@sss.pgh.pa.us
Whole thread Raw
In response to Index Question  ("Bierbryer, Andrew" <abierbryer@klsdiversified.com>)
List pgsql-general
"Bierbryer, Andrew" <abierbryer@klsdiversified.com> writes:
> I have created a table where a unique row is defined by 5 columns and
> have created an index on these 5 columns. If I then do a select with a
> where clause that only consists of 3 of these columns, will I get the
> speed benefits from the index that I have created, or will I need to
> create another index with only these 3 columns?

It should work fine if those are the three leading columns of the index.
If they're not, you might want another index.  This is not specific at
all to unique keys, it's a general property of multicolumn indexes.
Read
http://www.postgresql.org/docs/8.4/static/indexes.html
particularly 11.3 and 11.5

            regards, tom lane

pgsql-general by date:

Previous
From: "Bierbryer, Andrew"
Date:
Subject: Index Question
Next
From: Greg Smith
Date:
Subject: Re: Best practices for effective_io_concurrency