Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id D1B3E64FDA8 for ; Wed, 12 Nov 2008 20:27:40 -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 51928-06 for ; Wed, 12 Nov 2008 20:27:29 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.gransy.com (unknown [82.208.29.208]) by mail.postgresql.org (Postfix) with ESMTP id 2E0BE64FD9B for ; Wed, 12 Nov 2008 20:27:29 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mail.gransy.com (Postfix) with ESMTP id 23FEA7AC04C for ; Thu, 13 Nov 2008 01:27:27 +0100 (CET) Received: from mail.gransy.com ([127.0.0.1]) by localhost (nathalia.gransy.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c5mXDqvLuaeP for ; Thu, 13 Nov 2008 01:27:27 +0100 (CET) Received: from [192.168.1.1] (ip-89-102-139-23.karneval.cz [89.102.139.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.gransy.com (Postfix) with ESMTP id E76AB7AC006 for ; Thu, 13 Nov 2008 01:27:26 +0100 (CET) Message-ID: <491B7473.3050407@fuzzy.cz> Date: Thu, 13 Nov 2008 01:27:31 +0100 From: Tomas Vondra User-Agent: Thunderbird 2.0.0.9 (X11/20080213) MIME-Version: 1.0 CC: pgsql-performance@postgresql.org Subject: Re: Using index for IS NULL query References: <4919F2C6.4000303@fuzzy.cz> <1d709ecc0811111500i3c63e345qfa3be90264629256@mail.gmail.com> In-Reply-To: <1d709ecc0811111500i3c63e345qfa3be90264629256@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.681 tagged_above=0 required=5 tests=MISSING_HEADERS=1.581, RDNS_NONE=0.1 X-Spam-Level: * X-Archive-Number: 200811/117 X-Sequence-Number: 31848 Well, you're obviously right - I didn't know this. I guess I've found that the index is not used for null values, and deduced somehow that NULL values are not stored in the index. Thanks, it's nice to find out a 'bug' before it's too late :-) regards Tomas > Are you sure NULL values are not stored? btree, gist and bitmap index > and search for NULL values. > > select amname, amindexnulls, amsearchnulls from pg_am; > > amname | amindexnulls | amsearchnulls > --------+--------------+--------------- > btree | t | t > hash | f | f > gist | t | t > gin | f | f > bitmap | t | t > (5 rows) > > > Sincerely yours, > Vladimir Sitnikov