pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Antal Attila <antal.attila@ritek.hu>
Cc: pgsql-sql@postgresql.org
Subject: Re: Multi ordered select and indexing
Date: Fri, 23 Apr 2004 12:37:16 -0500
Message-ID: <20040423173716.GA7767@wolff.to> (raw)
In-Reply-To: <000301c4293f$ebf6b930$0b02010a@atesz>
References: <000301c4293f$ebf6b930$0b02010a@atesz>

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.



view thread (6+ messages)  latest in thread

Message-ID: <20040423173716.GA7767@wolff.to>
Permalink:  ../20040423173716.GA7767@wolff.to/
Also on:    postgresql.org/message-id/20040423173716.GA7767@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, antal.attila@ritek.hu
  Subject: Re: Multi ordered select and indexing
  In-Reply-To: <20040423173716.GA7767@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox