pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedReverse Index ... how to ...
4+ messages / 3 participants
[nested] [flat]
* Reverse Index ... how to ...
@ 2006-04-05 18:14 Marc G. Fournier <scrappy@postgresql.org>
2006-04-05 18:20 ` Re: Reverse Index ... how to ... Oleg Bartunov <oleg@sai.msu.su>
2006-04-05 19:06 ` Re: Reverse Index ... how to ... Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 4+ messages in thread
From: Marc G. Fournier @ 2006-04-05 18:14 UTC (permalink / raw)
To: pgsql-sql
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' ...
Thx
----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Reverse Index ... how to ...
2006-04-05 18:14 Reverse Index ... how to ... Marc G. Fournier <scrappy@postgresql.org>
@ 2006-04-05 18:20 ` Oleg Bartunov <oleg@sai.msu.su>
1 sibling, 0 replies; 4+ messages in thread
From: Oleg Bartunov @ 2006-04-05 18:20 UTC (permalink / raw)
To: Marc G. Fournier <scrappy@postgresql.org>; +Cc: pgsql-sql
On Wed, 5 Apr 2006, Marc G. Fournier wrote:
>
> 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' ...
use something like
select * into new_table from old_table order by some_key desc;
>
> Thx
>
> ----
> Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
> Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Reverse Index ... how to ...
2006-04-05 18:14 Reverse Index ... how to ... Marc G. Fournier <scrappy@postgresql.org>
@ 2006-04-05 19:06 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-04-05 19:14 ` Re: Reverse Index ... how to ... Marc G. Fournier <scrappy@postgresql.org>
1 sibling, 1 reply; 4+ messages in thread
From: Tom Lane @ 2006-04-05 19:06 UTC (permalink / raw)
To: Marc G. Fournier <scrappy@postgresql.org>; +Cc: pgsql-sql
"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)
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Reverse Index ... how to ...
2006-04-05 18:14 Reverse Index ... how to ... Marc G. Fournier <scrappy@postgresql.org>
2006-04-05 19:06 ` Re: Reverse Index ... how to ... Tom Lane <tgl@sss.pgh.pa.us>
@ 2006-04-05 19:14 ` Marc G. Fournier <scrappy@postgresql.org>
0 siblings, 0 replies; 4+ messages in thread
From: Marc G. Fournier @ 2006-04-05 19:14 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Marc G. Fournier <scrappy@postgresql.org>; pgsql-sql
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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2006-04-05 19:14 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-04-05 18:14 Reverse Index ... how to ... Marc G. Fournier <scrappy@postgresql.org>
2006-04-05 18:20 ` Oleg Bartunov <oleg@sai.msu.su>
2006-04-05 19:06 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-04-05 19:14 ` Marc G. Fournier <scrappy@postgresql.org>
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