Re: Boolean storage takes up 1 byte?

From: Thom Brown <thombrown(at)gmail(dot)com>
To: Sam Mason <sam(at)samason(dot)me(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Boolean storage takes up 1 byte?
Date: 2009-10-01 11:33:28
Message-ID: bddc86150910010433w3a33d091nb09e4ab7726b53f8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2009/10/1 Sam Mason <sam(at)samason(dot)me(dot)uk>

>
> bool_or and bool_and are aggregates that work over boolean data types.
>
>
Ah yes, that makes total sense! I knew max wouldn't be logical in such as
case, but couldn't think of the alternative. Thanks!

>
> I believe it's more to do with the fact that if you add a boolean column
> and then subsequently an int column then you're going to struggle to
> "pack" them efficiently. PG always puts columns on the "end" so that you
> can add a column in constant time (i.e. no need to rewrite the table
> in some common situations). Once you start doing this then packing is
> awkward and a single byte becomes much easier. Whether the value is
> NULL is stored elsewhere in the row.
>
>
That's clear now.

>
> > And does its storage as a byte affect indexing or query planning?
>
> Not sure which aspects you're referring to here, sorry.
>
> Giving my question more thought, I believe it's pointless.

You've answered my question. Thanks Sam.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ounce Snow 2009-10-01 13:30:24 error message on install [ REPOST from pgsql-novice ]
Previous Message Sam Mason 2009-10-01 11:03:48 Re: Boolean storage takes up 1 byte?