X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id EA2E130EBE9 for ; Mon, 16 Jun 2003 05:31:30 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 52647-02 for ; Mon, 16 Jun 2003 02:31:18 -0300 (ADT) Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) by svr1.postgresql.org (Postfix) with SMTP id E992C30E8CA for ; Mon, 16 Jun 2003 02:31:17 -0300 (ADT) Received: (qmail 8288 invoked by uid 1001); 16 Jun 2003 05:31:18 -0000 Date: Mon, 16 Jun 2003 00:31:18 -0500 From: "Jim C. Nasby" To: pgsql-performance@postgresql.org Subject: Partial index where clause not filtering through Message-ID: <20030616003118.S66185@flake.decibel.org> Reply-To: jim@nasby.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Archive-Number: 200306/76 X-Sequence-Number: 2160 I have the following index: street_range__street_locality_high_low_v btree (street_name_id, locality_id, addr_high_v, addr_low_v) WHERE (addr_high_v IS NOT NULL) The query has a where clause like this: FROM street_range s, input i WHERE 1=1 AND i.address_v IS NOT NULL AND s.locality_id = i.locality_id AND s.street_name_id = i.street_name_id AND s.addr_low_v <= i.address_v AND s.addr_high_v >= i.address_v As-is, it won't use the index. i.address_v IS NOT NULL AND s.addr_high_v >= i.address_v should mandate that s.addr_high_v must be not-null, if I'm remembering how nulls work correctly. (Actually, having any kind of comparison on s.addr_high_v should mandate NOT NULL since NULL != NULL, right?) Therefore the optimizer should be able to deduce that it can use the index. Adding AND s.addr_high_v IS NOT NULL to the where clause makes everything work fine, so there is a work-around. Just seems like a minor item to add to the TODO. -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?"