Re: CREATE INDEX .. ON table1 (field1 asc, field2 desc)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: CREATE INDEX .. ON table1 (field1 asc, field2 desc)
Дата
Msg-id 5805.1030287721@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: CREATE INDEX .. ON table1 (field1 asc, field2 desc)  (Alvaro Herrera <alvherre@atentus.com>)
Список pgsql-general
Alvaro Herrera <alvherre@atentus.com> writes:
>> I am new to PostgreSQL and databases in general, and I have this
>> question: why it is not possible to specify ordering when creating an
>> index?

> Because there is no point in doing so.  Postgres automatically scans an
> index in reverse direction if you want to use descending order.

But he wants, or says he wants, ASC order on the first column and DESC
on the second.  I concur with Martijn that this might just be a
beginner's mistake in giving the command ... but if that's really what
he wants then it doesn't correspond to either forward or reverse scan
of a normal index.  You would indeed need to make a custom opclass for
the second column in order to make an index that can be scanned in this
order.

            regards, tom lane

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