X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7FAA9D7ED4 for ; Sat, 27 Aug 2005 03:38:10 -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 48214-04 for ; Sat, 27 Aug 2005 06:38:08 +0000 (GMT) Received: from mail.travelamericas.com (unknown [206.130.134.147]) by svr1.postgresql.org (Postfix) with SMTP id 3D065D7EC6 for ; Sat, 27 Aug 2005 03:38:07 -0300 (ADT) Received: (qmail 12928 invoked from network); 27 Aug 2005 06:38:09 -0000 Received: from unknown (HELO ?10.0.0.253?) (10.0.0.253) by verkiel.travelamericas.com with SMTP; 27 Aug 2005 06:38:09 -0000 Message-ID: <43100A51.1040602@travelamericas.com> Date: Fri, 26 Aug 2005 23:38:09 -0700 From: Chris Travers User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Matt L." Cc: pgsql-sql@postgresql.org Subject: Re: booleans and nulls References: <20050821022557.21501.qmail@web35204.mail.mud.yahoo.com> In-Reply-To: <20050821022557.21501.qmail@web35204.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/259 X-Sequence-Number: 22487 Matt L. wrote: >Out of curiousity, > >1. Does a boolean column occupy 1byte of disk whether >or not the value is null or not? > > I believe so. >2. Is matching on IS NULL or = 0 more efficient? > > > Hmm... = 0 is the same as IS FALSE. Not the same as IS NULL. So I guess it is apples v. oranges.... >3. If I ix'd columns w/ null does postgres know >whatevers not indexed is null or would their be no >point? > > >I currently utilize null fields as 'not a value' has >meaning in a program i've been working on as I don't >want to put false in every column when i only need a >couple with a true/false value. > >I'm not joining tables on NULLS, just filtering w/ >them. > > Sounds like a partial index would be your best bet. Something like: CREATE index ON my_table WHERE my_bool IS NOT NULL Best Wishes, Chris Travers Metatron Technology Consulting