Re: Reversing NULLS in ORDER causes index not to be used?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Reversing NULLS in ORDER causes index not to be used?
Дата
Msg-id 226299.1608343379@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Reversing NULLS in ORDER causes index not to be used?  (Ken Tanzer <ken.tanzer@gmail.com>)
Ответы Re: Reversing NULLS in ORDER causes index not to be used?  (Ken Tanzer <ken.tanzer@gmail.com>)
Список pgsql-performance
Ken Tanzer <ken.tanzer@gmail.com> writes:
> Hi.  I'm wondering if this is normal or at least known behavior?
> Basically, if I'm specifying a LIMIT and also  NULLS FIRST (or NULLS LAST
> with a descending sort), I get a sequence scan and a couple of orders of
> magnitude slower query.  Perhaps not relevantly, but definitely ironically,
> the sort field in question is defined to be NOT NULL.

The index won't get credit for matching the requested ordering if it's
got the wrong null-ordering polarity.  There's not an exception for
NOT NULL columns.  If you know the column hasn't got nulls, why are
you bothering with a nondefault null-ordering request?

            regards, tom lane



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

Предыдущее
От: Ken Tanzer
Дата:
Сообщение: Reversing NULLS in ORDER causes index not to be used?
Следующее
От: Ken Tanzer
Дата:
Сообщение: Re: Reversing NULLS in ORDER causes index not to be used?