Bit string storage space?

Started by Stephen Robert Norrisabout 23 years ago2 messagesgeneral
Jump to latest
#1Stephen Robert Norris
srn@commsecure.com.au

The manual
(http://www.postgresql.org/users-lounge/docs/7.2/postgres/datatype-bit.html) doesn't say how much space a bit string uses, unlike for other types. Does anyone know how much space it uses for a n-bit string?

Stephen

#2Dennis Gearon
gearond@cvc.net
In reply to: Stephen Robert Norris (#1)
Re: Bit string storage space?

1 byte equals 8 bits in the bit string. Add 4 bytes minimum for the
'size_of' value for the field.

Example:

B'11011011010101101' 17 bits

(17 % 8) + 1 (round up) + 4 ( for size ) = 7 bytes to store 17 bits.
--

Carpe Dancem ;-)
-----------------------------------------------------------------
Remember your friends while they are alive
-----------------------------------------------------------------
Sincerely, Dennis Gearon