Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: Index on nullable column


  • From: Daniel CAUNE <d(dot)caune(at)free(dot)fr>
  • To: 'Tom Lane' <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 'Daniel Caune' <daniel(dot)caune(at)ubisoft(dot)com>
  • Cc: pgsql-sql(at)postgresql(dot)org
  • Subject: Re: Index on nullable column
  • Date: Sat, 25 Mar 2006 07:38:29 -0500
  • Message-id: <0IWO00E7BOG2MP90@VL-MH-MR001.ip.videotron.ca> <text/plain>

> > Is an index on a nullable column useful for retrieving rows having that
> > column null?
> 
> Nope, because IS NULL isn't an indexable operator.
> 
> You can make an end-run around that with a partial index, eg
> 
> 	create index fooi on foo(f1) where f1 is null
> 
> This can be used to satisfy queries using "where f1 is null", but it's
> not any good for any other purpose.
> 
> If you often do "where f1 is null and something-about-f2",
> you might get better mileage with
> 
> 	create index fooi on foo(f2) where f1 is null
> 
> but it's still a very specialized index.
> 

Thanks Tom.  I will use such an index even if it's very specialized; OLAP world is somewhat full of specialized index anyway... :-)

--
Daniel




Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group