Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/11/10 Bjørn T Johansen <btj@xxxxxxxxxx>:
> 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 using indexes 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.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux