Boolean storage takes up 1 byte?
От
Thom Brown
Тема
Boolean storage takes up 1 byte?
Дата
Msg-id
bddc86150910010337i19ffd46fm272d8127ed97cdbb@mail.gmail.com
Список
Дерево обсуждения
Boolean storage takes up 1 byte? Thom Brown <thombrown@gmail.com>
Re: Boolean storage takes up 1 byte? Sam Mason <sam@samason.me.uk>
Re: Boolean storage takes up 1 byte? Simon Riggs <simon@2ndQuadrant.com>
Re: Boolean storage takes up 1 byte? Tom Lane <tgl@sss.pgh.pa.us>
Re: Boolean storage takes up 1 byte? Thom Brown <thombrown@gmail.com>
Hi,
I've read the PostgreSQL documentation page on the boolean datatype (http://www.postgresql.org/docs/8.4/static/datatype-boolean.html) to find out what PostgreSQL's definition of a boolean is, as I believe it is distinctive from a bit(1) datatype (as you can't max() a boolean.. not sure what an efficient alternative to that is). However, I see that a boolean takes up 1 byte of storage, which is 8 bits. Is this due to the fact that the value can be null? I'm not clear as to how a null field is stored, or is that the point... nothing references is so it is defined as null? If that is the case, can't this be stored as 1 bit? And does its storage as a byte affect indexing or query planning?
Thom
I've read the PostgreSQL documentation page on the boolean datatype (http://www.postgresql.org/docs/8.4/static/datatype-boolean.html) to find out what PostgreSQL's definition of a boolean is, as I believe it is distinctive from a bit(1) datatype (as you can't max() a boolean.. not sure what an efficient alternative to that is). However, I see that a boolean takes up 1 byte of storage, which is 8 bits. Is this due to the fact that the value can be null? I'm not clear as to how a null field is stored, or is that the point... nothing references is so it is defined as null? If that is the case, can't this be stored as 1 bit? And does its storage as a byte affect indexing or query planning?
Thom
В списке pgsql-general по дате отправления