Re: Multicolumn Indexes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Thomas Yagel" <tyagel(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Multicolumn Indexes
Date: 2004-10-15 17:57:34
Message-ID: 11530.1097863054@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Thomas Yagel" <tyagel(at)yahoo(dot)com> writes:
> Right now the index that I have on timestamp is not used because the Primary
> Key(ID) index is chosen for ordering. If I place a multicolumn index on
> (timestamp, id) will that index be able to filter the timestamp and still be
> used for returning the ordered IDs?

You'd need to do that and also say "ORDER BY timestamp, id" not just
"ORDER BY id".

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GUNDUZ 2004-10-15 18:13:39 Re: pgsql cvs
Previous Message Tom Lane 2004-10-15 17:13:53 Re: Changing session ownership in a web app (or how to peel an onion)