Re: Btree index extension question
От | |
---|---|
Тема | Re: Btree index extension question |
Дата | |
Msg-id | Pine.LNX.4.33.0203152249490.965-100000@icarus.hades обсуждение исходный текст |
Ответ на | Re: Btree index extension question (Dmitry Tkach <dmitry@openratings.com>) |
Список | pgsql-general |
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?
В списке pgsql-general по дате отправления: