Re: Does not use index on query using "field is null"?

Поиск
Список
Период
Сортировка
От Vick Khera
Тема Re: Does not use index on query using "field is null"?
Дата
Msg-id AANLkTimbLZ6c55QAOKez8FqgwQOEQ5v+2owj=1yn3FSJ@mail.gmail.com
обсуждение исходный текст
Ответ на Does not use index on query using "field is null"?  (Bjørn T Johansen <btj@havleik.no>)
Список pgsql-general
2010/11/10 Bjørn T Johansen <btj@havleik.no>:
> select * from table where field is null
>
> And when I run explain, it tells me that it uses seq scan... Is this because pg thinks that seq scan is as fast as
usingindexes or because using index on "is null" queries does 
> not work?
>

Does the table have *lots* of NULLs in that column?  If the index is
not very selective, it may choose to use a seq scan since it will
result in fewer I/O ops.  This decision will be based on the relative
values of random_page_cost and seq_page_cost, and probably the
effective_cache_size as well.

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

Предыдущее
От: Bjørn T Johansen
Дата:
Сообщение: Does not use index on query using "field is null"?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Does not use index on query using "field is null"?