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

From: Bjørn T Johansen <btj(at)havleik(dot)no>
To: pgsql-general(at)postgresql(dot)org
Subject: Does not use index on query using "field is null"?
Date: 2010-11-10 12:07:49
Message-ID: 20101110130749.14dff805@pennywise.asp-as.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a query that looks like this...:

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?

Regards,

BTJ

--
-----------------------------------------------------------------------------------------------
Bjørn T Johansen

btj(at)havleik(dot)no
-----------------------------------------------------------------------------------------------
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
-----------------------------------------------------------------------------------------------

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vick Khera 2010-11-10 13:35:04 Re: Does not use index on query using "field is null"?
Previous Message Szymon Guz 2010-11-10 09:33:53 Re: Comments on tables