From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Szymon Guz <mabewlun(at)gmail(dot)com> |
Cc: | AI Rumman <rummandba(at)gmail(dot)com>, pgsql-general General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: index in desc order |
Date: | 2010-11-02 14:10:19 |
Message-ID: | 25586.1288707019@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Szymon Guz <mabewlun(at)gmail(dot)com> writes:
> On 2 November 2010 10:36, AI Rumman <rummandba(at)gmail(dot)com> wrote:
>> Is it possible to create an index in descending order?
> create index i on t(i desc);
Note that there is actually no point at all in such a declaration.
The planner is perfectly capable of using backwards indexscans at
need, so the above index doesn't do anything you couldn't do with
a regular ascending-order index.
The cases where this feature is actually worth something is where
you have a multi-column index and you need different sort orders
for the components, for example
create index xy on t (x asc, y desc);
which could be used to satisfy SELECT ... ORDER BY x ASC, y DESC.
The OP didn't say what he wanted to use the feature for, but
unless it's something like that, there's probably a better way.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Jonathan Tripathy | 2010-11-02 14:20:54 | Re: Replication |
Previous Message | Carlos Mennens | 2010-11-02 14:02:05 | Re: 8.4 Data Not Compatible with 9.0.1 Upgrade? |