array vs bit fields for masking

Started by Chip Nowacekalmost 14 years ago2 messagesgeneral
Jump to latest
#1Chip Nowacek
chip@twostewards.com

Hey. I'm new to postgresql. Impressive.

I am building an app with core tables in a central schema and user access
via views in separate schemas. I have to manage versioning and system
configuration at the row level. My initial thinking was to have a bit field
for each quality: version BIT(20), config(20). Each view would mask based
on those fields. Then (multi-dimensional) arrays crossed my mind. Any
performance / maintainability thoughts in using arrays vs bit fields?

Thanks,

Chip

#2Sergey Konoplev
sergey.konoplev@postgresql-consulting.com
In reply to: Chip Nowacek (#1)
Re: array vs bit fields for masking

Hi,

On Sun, Jun 17, 2012 at 7:03 PM, Chip Nowacek <chip@twostewards.com> wrote:

configuration at the row level. My initial thinking was to have a bit field
for each quality: version BIT(20), config(20). Each view would mask based on
those fields. Then (multi-dimensional) arrays crossed my mind. Any
performance / maintainability thoughts in using arrays vs bit fields?

If you intended to use this fields with partial indexes only
(http://www.postgresql.org/docs/9.1/static/indexes-partial.html) then
you will benefit in size. Otherwise I would advise to use arrays as
the are more feature rich and indexable (take a note of this
http://www.postgresql.org/docs/9.1/static/intarray.html).

Also look at the hstore
(http://www.postgresql.org/docs/9.1/static/hstore.html). You might
find it interesting to store the states in a more flexible way. Pay
attention to the index support in this case too.

--
Sergey Konoplev

a database architect, software developer at PostgreSQL-Consulting.com
http://www.postgresql-consulting.com

Jabber: gray.ru@gmail.com Skype: gray-hemp Phone: +79160686204