Unix Technical Forum

Bitmasks

This is a discussion on Bitmasks within the Pgsql Performance forums, part of the PostgreSQL category; --> Can indexes be used for bit-filtering queries? For example: create table tt ( flags integer not null default 0, ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 06:45 AM
Ivan Voras
 
Posts: n/a
Default Bitmasks

Can indexes be used for bit-filtering queries? For example:

create table tt (
flags integer not null default 0,
str varchar
);

select * from tt where (flags & 16) != 0;

I suspected radix trees could be used for this but it seems it doesn't
work that way.

If not, is there a way of quickly filtering by such "elements of a set"
that doesn't involve creating 32 boolean fields (which would also need
to be pretty uselessly indexed separately)?

Would strings and regular expressions work?

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 06:45 AM
Greg Stark
 
Posts: n/a
Default Re: Bitmasks

Ivan Voras <ivoras@fer.hr> writes:

> select * from tt where (flags & 16) != 0;
>
> I suspected radix trees could be used for this but it seems it doesn't work
> that way.


You would need a gist index method to make this work. I actually worked on one
for a while and had it working. But it wasn't really finished. If there's
interest I could finish it up and put it up somewhere like pgfoundry.

> If not, is there a way of quickly filtering by such "elements of a set" that
> doesn't involve creating 32 boolean fields (which would also need to be pretty
> uselessly indexed separately)?


You could create 32 partial indexes on some other column which wouldn't really
take much more space than a single index on that other column. But that won't
let you combine them effectively as a gist index would.

--
greg


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:19 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com