Re: Indexing null dates

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Indexing null dates
Дата
Msg-id 87ekqj5nms.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на Re: Indexing null dates  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-general
Bruce Momjian <pgman@candle.pha.pa.us> writes:

> Yes, nifty.  CREATE INDEX docs updated with:
>
> +    <literal>NULL</> values are not indexed by default.  The best way
> +    to index <literal>NULL</> values is to create a partial index using
> +    an <literal>IS NULL</> comparison.  <literal>IS NULL</> is more
> +    of a function call than a value comparison, and this is why a partial
> +    index works.

Uh, this is wrong.

NULLs are indexed. It's just that IS NULL cannot take advantage of it due to
technical details. These are NOT the same thing.

Saying "NULLs are not indexed" will confuse people because it will make them
think that they're not present in the index at all which is what Oracle does.

That has real consequences on queries. The most obvious being that

 SELECT * FROM foo ORDER BY bar

cannot take advantage of an index on bar. Oracle programmers are accustomed to
having to had a "WHERE bar IS NOT NULL" or else live with the full table scan
and sort.

--
greg

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

Предыдущее
От: Andreas
Дата:
Сообщение: Re: plan-reading extensive tutorial?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Indexing null dates