Thread: Bit string storage space?

Bit string storage space?

From
Stephen Robert Norris
Date:
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




Re: Bit string storage space?

From
Dennis Gearon
Date:
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