Re: query not using index for descending records?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>, email lists <lists(at)darrenmackay(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: query not using index for descending records?
Date: 2004-01-29 16:05:59
Message-ID: 20040129075643.D23153@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Thu, 29 Jan 2004, Bruno Wolff III wrote:

> On Thu, Jan 29, 2004 at 15:29:11 +0200,
> Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)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.

I'd thought that I'd previously sent a message containing a set of
definitions for the reverse opclasses (not meant for inclusion to the
system because I was making SQL functions that basically did -<normal
comparison function> to use as the function of the operator class, but
possibly worth playing with) but now that I actually search again, I don't
see it.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message mohan 2004-01-29 16:34:59 java.lang.StringIndexOutOfBoundsException: String index out of range: 23 at java.lang.String.charAt(String.java:460)
Previous Message Tom Lane 2004-01-29 15:50:21 Re: How to retrieve N lines of a text field.