pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Josh Berkus <josh@agliodbs.com>
Cc: Vincent-Olivier Arsenault <vincent@up4c.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: order by x DESC, y ASC indexing problem
Date: Thu, 3 Oct 2002 22:12:11 -0500
Message-ID: <20021004031211.GB3484@wolff.to> (raw)
In-Reply-To: <web-1771021@davinci.ethosmedia.com>
References: <3D9CF7EC.8080102@up4c.com>
	<web-1771021@davinci.ethosmedia.com>

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.



view thread (5+ messages)  latest in thread

Message-ID: <20021004031211.GB3484@wolff.to>
Permalink:  ../20021004031211.GB3484@wolff.to/
Also on:    postgresql.org/message-id/20021004031211.GB3484@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, josh@agliodbs.com, vincent@up4c.com
  Subject: Re: order by x DESC, y ASC indexing problem
  In-Reply-To: <20021004031211.GB3484@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