Re: Backwards index scan - Mailing list pgsql-general

From Alan Hodgson
Subject Re: Backwards index scan
Date
Msg-id 200606060804.45516@hal.medialogik.com
Whole thread Raw
In response to Backwards index scan  ("Carlos Oliva" <carlos@pbsinet.com>)
Responses Re: Backwards index scan
List pgsql-general
On June 6, 2006 07:59 am, "Carlos Oliva" <carlos@pbsinet.com> wrote:
> We are conducting a simple test to asses if the optimizer ever uses the
> index.  The table has several columns and the select statement is as
> follows: select * from ord0007 order by prtnbr, ordschdte desc.  The
> index that we added is "ord0007_k" btree (prtnbr, ordschdte).  Prtnbr is
> numeric(10,0) not null, and ordschdte is date.

You have to "order by prtnbr desc, ordschdte desc" to have the index used
the way you want.  You can re-order in an outer query if you need to.

--
Alan

pgsql-general by date:

Previous
From: "Carlos Oliva"
Date:
Subject: Backwards index scan
Next
From: Rafal Pietrak
Date:
Subject: Re: ALTER USER ..... PASSWORD ....