pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Travers <chris@travelamericas.com>
To: Matt L. <survivedsushi@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: booleans and nulls
Date: Fri, 26 Aug 2005 23:38:09 -0700
Message-ID: <43100A51.1040602@travelamericas.com> (raw)
In-Reply-To: <20050821022557.21501.qmail@web35204.mail.mud.yahoo.com>
References: <20050821022557.21501.qmail@web35204.mail.mud.yahoo.com>

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



view thread (3+ messages)  latest in thread

Message-ID: <43100A51.1040602@travelamericas.com>
Permalink:  ../43100A51.1040602@travelamericas.com/
Also on:    postgresql.org/message-id/43100A51.1040602@travelamericas.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: chris@travelamericas.com, survivedsushi@yahoo.com
  Subject: Re: booleans and nulls
  In-Reply-To: <43100A51.1040602@travelamericas.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox