Re: Reverse Index ... how to ...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Reverse Index ... how to ...
Дата
Msg-id 12527.1144263963@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Reverse Index ... how to ...  ("Marc G. Fournier" <scrappy@postgresql.org>)
Ответы Re: Reverse Index ... how to ...  ("Marc G. Fournier" <scrappy@postgresql.org>)
Список 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_unique1on tenk1  (cost=0.00..1572.00 rows=10000 width=244)
 
(1 row)

        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Oleg Bartunov
Дата:
Сообщение: Re: Reverse Index ... how to ...
Следующее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: Reverse Index ... how to ...