X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8A5CC5287E for ; Tue, 31 May 2005 00:21:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33144-04 for ; Tue, 31 May 2005 03:21:35 +0000 (GMT) Received: from exobox.exoweb.net (unknown [221.122.43.98]) by svr1.postgresql.org (Postfix) with SMTP id BF6455281E for ; Tue, 31 May 2005 00:21:25 -0300 (ADT) Received: (qmail 12007 invoked from network); 31 May 2005 03:21:23 -0000 Received: from exo185.exoweb.net (HELO tobias.nordicbet.invalid) (192.168.0.185) by 0 with SMTP; 31 May 2005 03:21:23 -0000 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id 7A71BE09C5; Tue, 31 May 2005 11:21:22 +0800 (CST) Date: Tue, 31 May 2005 11:21:20 +0800 From: Tobias Brox To: pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value Message-ID: <20050531032119.GH26100@tobias.exoweb.net> References: <20050531030207.GD26100@tobias.exoweb.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050531030207.GD26100@tobias.exoweb.net> Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/456 X-Sequence-Number: 12620 [Tobias Brox - Tue at 11:02:07AM +0800] > test=# explain select * from mock where b is NULL; > QUERY PLAN > -------------------------------------------------------------------- > Seq Scan on mock (cost=100000000.00..100000020.00 rows=6 width=8) > Filter: (b IS NULL) > (2 rows) (...) > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match That tip helped me :-) test=# explain select * from mock where (b IS NULL)=true; QUERY PLAN ---------------------------------------------------------------------- Index Scan using b_is_null on mock (cost=0.00..4.68 rows=1 width=8) Index Cond: ((b IS NULL) = true) (2 rows) -- Tobias Brox, Beijing