Re: Index not used with IS NULL - Mailing list pgsql-general

From Dima Tkach
Subject Re: Index not used with IS NULL
Date
Msg-id 3E4F1016.4050107@openratings.com
Whole thread Raw
In response to Re: Index not used with IS NULL  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Index not used with IS NULL  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Index not used with IS NULL  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
What is the problem with indexing nulls?
I had the similar problem some time ago, and created a custom set of
operators as a work around (that do the same thing as <=> for numbers,
but treat null as infinity and '=' returns true if both operand are
null, and false if only one is)...
It seems to work fine.
The only problem is, that it is kinda cumbersome to create custom
opclasses in postgres, and also, that I don't want to create the same
wrappers for all possible types (int2,int4,int8,float etc)...

It would be a lot nicer if the default operators could handle that...
Why can it not be done?

Thanks!

Dima

Tom Lane wrote:
> Nick Wellnhofer <wellnhofer@aevum.de> writes:
>
>>If I have a query like
>>SELECT * FROM table WHERE key IS NULL
>>and an index on column "key", a sequential scan is used.
>
>
> IS NULL is not an indexable operator.
>
> I suggest reconsidering your data representation, as this is unlikely to
> change soon...
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


pgsql-general by date:

Previous
From: Alan Gutierrez
Date:
Subject: is current_timestamp unique for a transaction?
Next
From: Bruno Wolff III
Date:
Subject: Re: [SQL] is current_timestamp unique for a transaction?