pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Bitmasks
2+ messages / 2 participants
[nested] [flat]

* Bitmasks
@ 2005-12-10 17:12 Ivan Voras <ivoras@fer.hr>
  2005-12-11 06:12 ` Re: Bitmasks Greg Stark <gsstark@mit.edu>
  0 siblings, 1 reply; 2+ messages in thread

From: Ivan Voras @ 2005-12-10 17:12 UTC (permalink / raw)
  To: pgsql-performance

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?



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Bitmasks
  2005-12-10 17:12 Bitmasks Ivan Voras <ivoras@fer.hr>
@ 2005-12-11 06:12 ` Greg Stark <gsstark@mit.edu>
  0 siblings, 0 replies; 2+ messages in thread

From: Greg Stark @ 2005-12-11 06:12 UTC (permalink / raw)
  To: Ivan Voras <ivoras@fer.hr>; +Cc: pgsql-performance

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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-12-11 06:12 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-12-10 17:12 Bitmasks Ivan Voras <ivoras@fer.hr>
2005-12-11 06:12 ` Greg Stark <gsstark@mit.edu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox