Efficient Boolean Storage

Поиск
Список
Период
Сортировка
От Chris White
Тема Efficient Boolean Storage
Дата
Msg-id 000901c29b31$64fb2a80$9d03a8c0@archnet2.atgsd.com
обсуждение исходный текст
Ответы Re: Efficient Boolean Storage  (Richard Huxton <dev@archonet.com>)
Список pgsql-general

Hello,

 

I need to store many (e.g. 30) booleans and am wondering what is the most efficient way to store them.  I can think of four options.

 

Option 1...Use ‘bool’ data type

No good since each value will require 1 byte rather than 1 bit.

 

Option 2...Use ‘bit string’ data type

Good since bit status is visible e.g. 0001000110

Questionable...How much storage used?  Storage = 1 byte per bit?  Or Storage = # of bits rounded to nearest byte?

 

Option 3...Use sets of ‘char’

Good since compact.  Storage is known...8 booleans = 8 bits = 1 byte

Bad since less obvious to casual database viewer.

 

Option 4...Use individual ‘bit’ data types for each Boolean

Good since obvious to casual database viewer.

Questionable...Probably uses 1 byte per bit.

 

Thanks in advance for your help.  I’m new to PostgreSQL.  Yet, I’m architecting a database where storage space is at a premium.

 

- Chris

 

В списке pgsql-general по дате отправления:

Предыдущее
От: Joseph Shraibman
Дата:
Сообщение: set in transaction
Следующее
От: Oliver Elphick
Дата:
Сообщение: Re: Postgresql -- initial impressions and comments