Re: Bitmask trickiness - Mailing list pgsql-general

From Peter Hunsberger
Subject Re: Bitmask trickiness
Date
Msg-id AANLkTin8IcR9IsH9f0p-edWWceCAOnahkAYGnoO8HKzl@mail.gmail.com
Whole thread Raw
In response to Re: Bitmask trickiness  (Howard Rogers <hjr@diznix.com>)
Responses Re: Bitmask trickiness  (Howard Rogers <hjr@diznix.com>)
List pgsql-general
On Wed, Jul 21, 2010 at 11:13 PM, Howard Rogers <hjr@diznix.com> wrote:
>
> On Thu, Jul 22, 2010 at 1:02 PM, Scott Marlowe <scott.marlowe@gmail.com> wrote:
>
>
> >>
> >> Why on Earth would I want to store this sort of stuff in a bit string?!
> >
> > Because you are manipulating bits and not integers?  I guess there are
> > 10 kinds of people, those who like think in binary and those who
> > don't.
> >
> >> I don't know about you, but I find looking at 21205 a darn'd site
> >> easier than staring blankly at 101001011010101!!

<snip> lots of stuff</snip>

> >
> > Note you can cast integer to bitstring, but there may be some odd
> > behaviour for sign bits and such.  Which is again why I'd use the
> > right type for the job, bit string.  But it's your project.
> >
>
> Quoting...
>
> > Because you are manipulating bits and not integers?  I guess there are
> > 10 kinds of people, those who like think in binary and those who
> > don't.
>
> Er, no. 21205 is not an integer. It's an encoded bit of magic.
>

In that case your database design is fundamentally broken.  A database
should have content fields that map to the needs of the application.
As you describe your application requirements, that is a bit string
and not an integer.  Use bit strings and your application logic is
transparent, obvious and easy to maintain.  Use integers and you have
to resort to "magic".  As you say, it's your choice, but you came here
looking for advice and the advice you were given is very good....

--
Peter Hunsberger

pgsql-general by date:

Previous
From: Andreas Joseph Krogh
Date:
Subject: Clarification of the "simple" dictionary
Next
From: P Kishor
Date:
Subject: optimizing daily data storage in Pg