Re: Multicolumn indexes and ORDER BY

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Jernej Kos <kostko(at)jweb-network(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Multicolumn indexes and ORDER BY
Date: 2004-06-16 06:12:13
Message-ID: 20040616061213.GA3567@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jun 16, 2004 at 07:12:26AM +0200, Jernej Kos wrote:
> I have a multicolumn index on two columns. If i use the columns in ORDER BY
> like this:
> ORDER BY col1, col2;
>
> The index is used. But, if one column is sorted DESC it is not used:
> ORDER BY col1 DESC, col2;
>
> How can i make this work ?

Try:

ORDER BY col1 DESC, col2 desc;

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael 2004-06-16 06:31:42 Query
Previous Message Adam Smith 2004-06-16 05:24:30 Re: Installation problem - mutex_lock/unlock or libpq.so ?