pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: fcanedo@hotpop.com
To: Dmitry Tkach <dmitry@openratings.com>
Cc: fcanedo@hotpop.com
Cc: pgsql-admin@postgresql.org
Cc: pgsql-general@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: [GENERAL] Btree index extension question
Date: Fri, 15 Mar 2002 22:57:24 +0100 (CET)
Message-ID: <Pine.LNX.4.33.0203152249490.965-100000@icarus.hades> (raw)
In-Reply-To: <3C927F13.3000007@openratings.com>



On Fri, 15 Mar 2002, Dmitry Tkach wrote:

> fcanedo@hotpop.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?






view thread (12+ messages)  latest in thread

Message-ID: <Pine.LNX.4.33.0203152249490.965-100000@icarus.hades>
Permalink:  ../Pine.LNX.4.33.0203152249490.965-100000@icarus.hades/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0203152249490.965-100000@icarus.hades

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: fcanedo@hotpop.com, dmitry@openratings.com, pgsql-admin@postgresql.org, pgsql-general@postgresql.org
  Subject: Re: [GENERAL] Btree index extension question
  In-Reply-To: <Pine.LNX.4.33.0203152249490.965-100000@icarus.hades>
  References: <3C927F13.3000007@openratings.com> <Pine.LNX.4.33.0203152249490.965-100000@icarus.hades>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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