Re: order by x DESC, y ASC indexing problem - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: order by x DESC, y ASC indexing problem
Date
Msg-id 20021004031211.GB3484@wolff.to
Whole thread Raw
In response to Re: order by x DESC, y ASC indexing problem  ("Josh Berkus" <josh@agliodbs.com>)
List pgsql-sql
On Thu, Oct 03, 2002 at 19:30:59 -0700, Josh Berkus <josh@agliodbs.com> wrote:
> Vincent,
> 
> > SELECT * FROM TABLE1 ORDER BY X DESC, Y ASC;
> > 
> > (X is a date and Y a varchar)
> > 
> > What would that index be?
> > 
> > Is there a function I can use, to invert x (the date), so that I can
> > make a query / index set like :
> 
> PostgreSQL's sorting mechanism can use an index either ascending or
> descending; it does not make a difference.

Note this is referring to a multicolumn index. To use all columns of
a multicolumn index the sort directions all need to be the same.

However you are right to point out that this may not be a big deal for
many applications where using the index on the first column gets the
majority of the speed up.


pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: order by x DESC, y ASC indexing problem
Next
From: Tom Lane
Date:
Subject: Re: order by x DESC, y ASC indexing problem