Re: query not using index for descending records? - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: query not using index for descending records?
Date
Msg-id 20040129140655.GA14885@wolff.to
Whole thread Raw
In response to Re: query not using index for descending records?  (Achilleus Mantzios <achill@matrix.gatewaynet.com>)
Responses Re: query not using index for descending records?
Re: query not using index for descending records?
List pgsql-sql
On Thu, Jan 29, 2004 at 15:29:11 +0200, Achilleus Mantzios <achill@matrix.gatewaynet.com> wrote:
> O kyrios Bruno Wolff III egrapse stis Jan 29, 2004 :
> 
> As i see there was a thread
> http://archives.postgresql.org/pgsql-hackers/2003-05/msg00762.php
> dealing with this issue, assuming the "correct" order by
> should be "order by datetime ASC, id DESC".

So you really didn't want them in the reverse order?

> Do you know of any progress for declaring the direction of each
> column in a multicolumn index?

If you are using 7.4 you can use a functional index to get around this.
Assuming id is a numeric type, you can make an index on datetime and
(-id) and sort by datetime, -id and the index should get used.

This should still get fixed at some point, as this trick doesn't work
for types for which the - operator exists. But I haven't heard of
anyone working on it for 7.5, so don't expect a real fix any time soon.


pgsql-sql by date:

Previous
From:
Date:
Subject: Re:
Next
From: "MUKTA"
Date:
Subject: Re: