Simon Riggs <simon@2ndQuadrant.com> writes:
> It might be possible to make BOOLEAN NOT NULL use the null bit to
> represent the actual data value and then have the column use no
> additional bytes, except when we don't store the null bitmap at all.
> Just needs people to make it happen cleanly, if that's possible.
I really doubt that any scheme to pack booleans tighter would be a
net win. It'd make the core tuple-assembly and -disassembly loops more
complicated, hence slower and harder to maintain. Everybody would pay
that price whether or not they ever saved a byte from it.
It's worth noting also that you don't save anything from packing a bool
unless the *next* field in the row has a weak enough alignment
requirement that it can be moved over. In a majority of cases this
would mean that you'd need at least five adjacent bool columns before
you have any shot at winning anything --- with four or less, a following
column with int alignment will stay right where it is.
If you do have lots and lots of bool columns, it might possibly be worth
the trouble to represent them as a combined BIT(n) column ...
regards, tom lane