Re: Bit datatype performance?

From: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Bit datatype performance?
Date: 2011-09-15 14:14:59
Message-ID: 86hb4dsxi4.fsf@protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <CAPHN3JX1YNxnGsu3q5A0wGqMMwjXMcmu8LnZ72jepE2A=t23hA(at)mail(dot)gmail(dot)com>,
Antonio Vieiro <antonio(at)antonioshome(dot)net> writes:

> 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?

I think the best way is to put the tags into a hstore column. With a
GiST index on that column access is very fast.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-09-15 14:26:17 Re: Why is this query running slowly?
Previous Message Adrian Klaver 2011-09-15 14:03:28 Re: pg_dump with select command