Re: [GENERAL] Btree index extension question

From: <fcanedo(at)hotpop(dot)com>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: <fcanedo(at)hotpop(dot)com>, <pgsql-admin(at)postgresql(dot)org>, <pgsql-general(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: [GENERAL] Btree index extension question
Date: 2002-03-15 21:57:24
Message-ID: Pine.LNX.4.33.0203152249490.965-100000@icarus.hades
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general pgsql-sql

On Fri, 15 Mar 2002, Dmitry Tkach wrote:

> fcanedo(at)hotpop(dot)com wrote:
>
> >
> >If postgresql does bitwise operations, then you can use that instead of
> >defining new operators. Just construct a number for all the columns that
> >need to be true and do a bitwise 'and' with the stored value. (eg. (7 &
> >stored_val) = 7)
> >
>
> Yeah... The thing is that I want to be able to the index. And to use the
> index, I need BOOLEAN
> operators (this seems to be the LEAST of my problems,but anyway) - so, I
> have to define 'wrappers' around the standard bitwise operations - e.g.
> a <<= b ---> a & b = a;

Ok, let's see whether we understand each other:

1. Make a column that contains the bitstring of your 15 boolean
columns. Let's call it bitstring.
2. bitstring is calculated on each insert or update by a trigger.
3. Make an index on bitstring.
4. Make a query to find the records that have a1, a2 and a3 set to true,
like so:

SELECT * FROM table where (bitstring & 7) = 7;

Will this not give you the correct answer and use the index on bitstring?

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Bob Smith 2002-03-15 22:12:14 Re: Errors on VACUUM
Previous Message fcanedo 2002-03-15 21:15:10 Re: [GENERAL] Btree index extension question

Browse pgsql-general by date

  From Date Subject
Next Message Dominic J. Eidson 2002-03-15 22:23:10 Re: How to catch NOTIFY messages with PHP
Previous Message fcanedo 2002-03-15 21:15:10 Re: [GENERAL] Btree index extension question

Browse pgsql-sql by date

  From Date Subject
Next Message Dmitry Tkach 2002-03-15 23:09:07 Re: Btree index extension question
Previous Message fcanedo 2002-03-15 21:15:10 Re: [GENERAL] Btree index extension question