Received: from amsfep11-int.chello.nl (amsfep11-int.chello.nl [213.46.243.19]) by postgresql.org (Postfix) with ESMTP id A5FC8475EFA; Fri, 15 Mar 2002 16:56:39 -0500 (EST) Received: from icarus.hades ([62.163.197.161]) by amsfep11-int.chello.nl (InterMail vM.5.01.03.06 201-253-122-118-106-20010523) with ESMTP id <20020315215640.XRIK1209.amsfep11-int.chello.nl@icarus.hades>; Fri, 15 Mar 2002 22:56:40 +0100 Date: Fri, 15 Mar 2002 22:57:24 +0100 (CET) From: X-X-Sender: Reply-To: To: Dmitry Tkach Cc: , , , Subject: Re: [GENERAL] Btree index extension question In-Reply-To: <3C927F13.3000007@openratings.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200203/237 X-Sequence-Number: 3771 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?