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

From Tom Lane
Subject Re: Index not used with IS NULL
Date
Msg-id 20830.1045543499@sss.pgh.pa.us
Whole thread Raw
In response to Re: Index not used with IS NULL  (Dennis Gearon <gearond@cvc.net>)
List pgsql-general
Dennis Gearon <gearond@cvc.net> writes:
> so NULLs **DON'T** count in a unique index? You can have more than one
> NULL in a single column UNIQUE constraint? I guess I am showing my
> ignorance, I thought you could only have one.

Unique indexes enforce SQL92 unique constraints, which are defined by
the spec thusly (sec 4.10):

         A unique constraint is satisfied if and only if no two rows in
         a table have the same non-null values in the unique columns.

If this doesn't seem right to you, you have not grokked the concept of
NULL.  Two nulls are never "equal" per spec.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Index not used with IS NULL
Next
From: Tom Lane
Date:
Subject: Re: Index not used with IS NULL