Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 6095865015A for ; Tue, 11 Nov 2008 16:50:56 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40991-03 for ; Tue, 11 Nov 2008 16:50:53 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from 137086.vserver.de (static-ip-62-75-137-86.inaddr.intergenia.de [62.75.137.86]) by mail.postgresql.org (Postfix) with ESMTP id CE87A6504CF for ; Tue, 11 Nov 2008 16:50:52 -0400 (AST) Received: from a-kretschmer.de (p54B38712.dip0.t-ipconnect.de [84.179.135.18]) (authenticated bits=0) by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id mABKooA8030018 for ; Tue, 11 Nov 2008 21:50:50 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 4.69) (envelope-from ) id 1L00CH-00049C-GI for pgsql-performance@postgresql.org; Tue, 11 Nov 2008 21:50:49 +0100 Date: Tue, 11 Nov 2008 21:50:49 +0100 From: Andreas Kretschmer To: pgsql-performance@postgresql.org Subject: Re: Using index for IS NULL query Message-ID: <20081111205049.GA15899@tux> References: <12244.1226436315@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <12244.1226436315@sss.pgh.pa.us> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/80 X-Sequence-Number: 31811 Tom Lane schrieb: > "Andrus" writes: > > Index is not used for > > is null > > > How to fix ? > > Update to something newer than 8.1 (specifically, you'll need 8.3). Right. For my example in the other mail: test=*# create index idx_foo on foo(i); CREATE INDEX test=*# explain analyse select * from foo where i is null; QUERY PLAN -------------------------------------------------------------------------------------------------------------------- Bitmap Heap Scan on foo (cost=95.11..4780.49 rows=5000 width=8) (actual time=0.052..0.053 rows=1 loops=1) Recheck Cond: (i IS NULL) -> Bitmap Index Scan on idx_foo (cost=0.00..93.86 rows=5000 width=0) (actual time=0.047..0.047 rows=1 loops=1) Index Cond: (i IS NULL) Total runtime: 0.076 ms Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknown) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°