X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 8A9E09DCC53 for ; Sat, 25 Mar 2006 08:38:25 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23285-04 for ; Sat, 25 Mar 2006 08:38:28 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by postgresql.org (Postfix) with ESMTP id 84FCE9DCAB9 for ; Sat, 25 Mar 2006 08:38:23 -0400 (AST) Received: from lythanhphu ([66.130.233.129]) by VL-MH-MR001.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0IWO00E7AOG2MP90@VL-MH-MR001.ip.videotron.ca> for pgsql-sql@postgresql.org; Sat, 25 Mar 2006 07:38:26 -0500 (EST) Date: Sat, 25 Mar 2006 07:38:29 -0500 From: Daniel CAUNE Subject: Re: Index on nullable column In-reply-to: <12727.1143244097@sss.pgh.pa.us> To: 'Tom Lane' , 'Daniel Caune' Cc: pgsql-sql@postgresql.org Message-id: <0IWO00E7BOG2MP90@VL-MH-MR001.ip.videotron.ca> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Mailer: Microsoft Office Outlook, Build 11.0.6353 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7BIT Thread-index: AcZPnXsTCsdqkOq1TaiQr6c4/tgv2AAasNxw X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.496 required=5 tests=[AWL=0.496] X-Spam-Score: 0.496 X-Spam-Level: X-Archive-Number: 200603/408 X-Sequence-Number: 24754 > > 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