Indexing a Bit String column

From: George Oakman <oakmang(at)hotmail(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Indexing a Bit String column
Date: 2009-02-24 15:10:56
Message-ID: COL115-W36815F9A82AE0EA0CA520EAFAF0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi all,

I am planning to use the Bit String data type for a large number of binary strings, e.g.
CREATE TABLE myTable (myBitStringCol BIT(3));

I will need to perform & (bitwise AND) operations using SELECT on this column, e.g.
SELECT * FROM myTable WHERE myBitStringCol & B'101' = myBitStringCol;

To optimise this type of SELECT statement, I guess I’ll have to build an index on the Bit String column, e.g.
CREATE INDEX myBitStringCol_idx ON myTable (myBitStringCol);

Is it all I need to do? Will PgSQL know how to index properly a Bit String column? Should I build the index using a special method, e.g.
CREATE INDEX myBitStringCol_idx ON myTable USING gist(myBitStringCol);

Since we’re already talking of a Bit String column, the USING gist() statement looks a bit redundant to me. Basically, I though I would ask if I need to do anything special when indexing a BIT column.

Thanks for your comments.

George.



_________________________________________________________________
Twice the fun—Share photos while you chat with Windows Live Messenger. Learn more.
http://www.microsoft.com/uk/windows/windowslive/products/messenger.aspx

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martin Gainty 2009-02-24 15:22:29 Re: Oracle Functions to PostgreSQL
Previous Message Aidan Van Dyk 2009-02-24 15:05:47 Re: High cpu usage after many inserts