Re: Useless index

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Useless index
Дата
Msg-id 9035.1013702751@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Useless index  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: Useless index  (Brian McCane <bmccane@mccons.net>)
Список pgsql-admin
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> In fact, I am unsure why you are specifying the primary column in the
> ORDER BY anyway if you know it will be a single value, except perhaps to
> try and get it to use the index, right?

Exactly.  The sort ordering of the index is (col1,col2) while the
query as originally written wanted an ordering of (col2 desc).
The planner's not smart enough to realize that since the WHERE
constrains col1 to a single value, you could pretend the query
requests an ordering of (col1 desc, col2 desc) which is compatible
with the index.

            regards, tom lane

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Useless index
Следующее
От: Brian McCane
Дата:
Сообщение: Re: Useless index