Re: Bit datatype performance? - Mailing list pgsql-general

From David Johnston
Subject Re: Bit datatype performance?
Date
Msg-id E7D3F37E-B2B2-439D-AEA3-6CE4533327D3@yahoo.com
Whole thread Raw
In response to Bit datatype performance?  (Antonio Vieiro <antonio@antonioshome.net>)
List pgsql-general
On Sep 14, 2011, at 6:00, Antonio Vieiro <antonio@antonioshome.net> wrote:

> Hi all,
>
> One of my entities 'E' may be 'tagged' with an arbitrary set of 256 tags 'T'.
>
> A first approach could be to add a M:N relationship between 'E' and 'T'.
>
> A second way to do this could be to add a BIT(256) datatype to 'E',
> setting bits to '1' if the entity is tagged with each one of the 256
> tags (i.e. using a 'bitmask' on the set of tags).
>
> Since querying entities 'E' with a certain set of tags 'T' must be
> very fast I was wondering if the second approach would be faster. What
> do you think?
>
> Thanks for any hints,
> Antonio
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

Dealing with 256 arbitrary ones and zeros instead of meaningful named tags seems to be asking for mega-confusion.

If performance is really that important do both and run some performance tests.

If the tag set ever changes a schema change will be needed for the bit version but not the two-table version.

David J.

pgsql-general by date:

Previous
From: Marcos Hercules Santos
Date:
Subject: using trigger to change status in one table from the modification in other table
Next
From: Radosław Smogura
Date:
Subject: Re: Bit datatype performance?