Skip site navigation (1) Skip section navigation (2)

Re: query not using index for descending records?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
Cc: 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 14:06:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
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
> 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.

In response to


pgsql-sql by date

Next:From: MUKTADate: 2004-01-29 14:15:34
Subject: Re:
Previous:From: emailDate: 2004-01-29 13:36:01
Subject: Re:

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group