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

From Bruno Wolff III
Subject Re: Multi ordered select and indexing
Date
Msg-id 20040423173716.GA7767@wolff.to
Whole thread Raw
In response to Multi ordered select and indexing  ("Antal Attila" <antal.attila@ritek.hu>)
List pgsql-sql
On Fri, Apr 23, 2004 at 16:33:14 +0200, Antal Attila <antal.attila@ritek.hu> wrote:
> 
> 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"?  

Another option you might have is using functional indexes. If you are using
7.4.x or greater and one of the columns has a reasonable - operator
(pretty much this is the numeric types) then you can have an index on
(col1, (-col2)) and then order by col1, -col2.

The main advantage is that this is simpler than making a new opclass.
If you have already gone to that trouble it may be better to stick with it.


pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Multi ordered select and indexing
Next
From: "Jaime Casanova"
Date:
Subject: Re: lifetime of temp schema versus compiled image of plpgsql proc