Re: Indexing a Bit String column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: George Oakman <oakmang(at)hotmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Indexing a Bit String column
Date: 2009-02-24 15:46:38
Message-ID: 9271.1235490398@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> Note that something like "WHERE myBitStringCol & B'101'" might be selecting
> too much of your table to make an index useful anyways. If each bit is set in
> half the table then you're talking about selecting 3/4 of the table in which
> case a full table scan would be more efficient than any index.

If the expectation is that the bitstring is mostly zeroes, I wonder
whether the OP wouldn't be better off using an integer-array
representation, ie instead of '00000101' store '{6,8}'. Then he could
use the existing GIST or GIN support for integer array operations.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message George Oakman 2009-02-24 16:39:44 Re: Indexing a Bit String column
Previous Message Gregory Stark 2009-02-24 15:35:58 Re: Indexing a Bit String column