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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bjørn T Johansen <btj(at)havleik(dot)no>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Does not use index on query using "field is null"?
Date: 2010-11-10 15:00:43
Message-ID: 3520.1289401243@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?ISO-8859-1?Q?Bj=F8rn?= T Johansen <btj(at)havleik(dot)no> writes:
> 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?

What PG version? Releases before 8.3 do not think that IS NULL is an
indexable condition.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bjørn T Johansen 2010-11-10 15:21:49 Re: Does not use index on query using "field is null"?
Previous Message Vick Khera 2010-11-10 13:35:04 Re: Does not use index on query using "field is null"?