From: Marc G. Fournier <scrappy@postgresql.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Marc G. Fournier <scrappy@postgresql.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Reverse Index ... how to ...
Date: Wed, 5 Apr 2006 16:14:44 -0300 (ADT)
Message-ID: <20060405161430.H947@ganymede.hub.org> (raw)
In-Reply-To: <12527.1144263963@sss.pgh.pa.us>
References: <20060405151239.F947@ganymede.hub.org>
<12527.1144263963@sss.pgh.pa.us>
On Wed, 5 Apr 2006, Tom Lane wrote:
> "Marc G. Fournier" <scrappy@postgresql.org> writes:
>> I'm still searching through Google and whatnot, but not finding anything
>> off the bat ... is there some way of creating a 'REVERSE INDEX' on a
>> column in a table?
>
>> For instance, when I do a 'CLUSTER' to sort a table based on an INDEX, I'd
>> like to sort it in reverse order, so would need the INDEX to go from
>> 'GREATEST to LOWEST', vs 'LOWEST to GREATEST' ...
>
> You shouldn't need to worry about that during CLUSTER, as the system is
> perfectly capable of scanning an index in either forward or backward
> order at runtime. For example,
>
> regression=# explain select * from tenk1 order by unique1;
> QUERY PLAN
> ------------------------------------------------------------------------------------
> Index Scan using tenk1_unique1 on tenk1 (cost=0.00..1572.00 rows=10000 width=244)
> (1 row)
>
> regression=# explain select * from tenk1 order by unique1 desc;
> QUERY PLAN
> ---------------------------------------------------------------------------------------------
> Index Scan Backward using tenk1_unique1 on tenk1 (cost=0.00..1572.00 rows=10000 width=244)
> (1 row)
Perfect, that was what I was looking for, thx ...
----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664
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: scrappy@postgresql.org, tgl@sss.pgh.pa.us
Subject: Re: Reverse Index ... how to ...
In-Reply-To: <20060405161430.H947@ganymede.hub.org>
* 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