Re: Multi ordered select and indexing - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: Multi ordered select and indexing
Date
Msg-id 20040423093937.B17459@megazone.bigpanda.com
Whole thread Raw
In response to Multi ordered select and indexing  ("Antal Attila" <antal.attila@ritek.hu>)
List pgsql-sql
On Fri, 23 Apr 2004, Antal Attila wrote:

> Hi!
>
> We have a complex problematic area. What is the simplest solution for
> the next query type:
>
>   SELECT * FROM tablename ORDER BY col1 ASC, col2 DESC;
>
> In our experience, postgres cannot use a multi-colum index on (col1,
> col2) in this situation, becouse there are different directions after
> ORDER BY. Is custom operator class the easiest solution, which can solve
> the reverse indexing on col2? Our problem with this solution, is that we
> have to replace "DESC" with "USING myoperator". Is it possible, that
> postgres can recognize "myoperator" without replacing "DESC"?

Yes.  You should be able to make an opclass where the operators are the
standard operators but in a different order which should get used when
doing DESC. I think there should be examples in the archives.


pgsql-sql by date:

Previous
From: Martin Marques
Date:
Subject: Re: CONTEXT on PL/pgSQL
Next
From: Bruno Wolff III
Date:
Subject: Re: Multi ordered select and indexing