Boolean storage takes up 1 byte?

From: Thom Brown <thombrown(at)gmail(dot)com>
To: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Boolean storage takes up 1 byte?
Date: 2009-10-01 10:37:40
Message-ID: bddc86150910010337i19ffd46fm272d8127ed97cdbb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I've read the PostgreSQL documentation page on the boolean datatype (
http://www.postgresql.org/docs/8.4/static/datatype-boolean.html) to find out
what PostgreSQL's definition of a boolean is, as I believe it is distinctive
from a bit(1) datatype (as you can't max() a boolean.. not sure what an
efficient alternative to that is). However, I see that a boolean takes up 1
byte of storage, which is 8 bits. Is this due to the fact that the value
can be null? I'm not clear as to how a null field is stored, or is that the
point... nothing references is so it is defined as null? If that is the
case, can't this be stored as 1 bit? And does its storage as a byte affect
indexing or query planning?

Thom

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-10-01 11:03:48 Re: Boolean storage takes up 1 byte?
Previous Message Rakotomandimby Mihamina 2009-10-01 09:47:46 [OT] Relocation lookup