Received: from exchange.hq.openratings.com (adsl-141-154-210-2.ba-dsg.net [141.154.210.2]) by postgresql.org (Postfix) with ESMTP id 55E61476506; Fri, 15 Mar 2002 17:08:15 -0500 (EST) Received: from openratings.com (cancun.hq.openratings.com [10.0.0.225]) by exchange.hq.openratings.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id GPKPL5X1; Fri, 15 Mar 2002 17:08:33 -0500 Message-ID: <3C9285B7.10203@openratings.com> Date: Fri, 15 Mar 2002 18:37:27 -0500 From: Dmitry Tkach User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.7+) Gecko/20020123 X-Accept-Language: en-us MIME-Version: 1.0 To: fcanedo@hotpop.com Cc: pgsql-admin@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: Btree index extension question References: Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200203/849 X-Sequence-Number: 22221 > > > >SELECT * FROM table where (bitstring & 7) = 7; > >Will this not give you the correct answer and use the index on bitstring? > Yes, and know... (Yes, it will give th ecorrect answer, and NO it will not use the index). The thing is, that it will only use a (btree) index for one of the 'comparison' operators (<=, <, =, >, >=), that compare the value in the table with the query parameter - so, bitstring = 7, or bitstring < 7 etc... will work, but 'do_something_to_bitstring = 7' will not (I mean, it will, but it won't use the index). So, the idea is to redefine those comparison operators for the index, so that I could use one of them fopr my purpose - for example (as I mentioned in the original message), I was trying to define a '<<=' ("less or equals") operator as a <<= b iff a & b = a. My problem is that (as far as I understand) the way I am doing it will not work (my set of operators doesn't define a strict ordering, so that not any pair of values is comparable) :-( And what I am looking for is either a suggestion of how this strict ordering can be defined, or a description of what exactly the btree needs to work (I suspect, that completely strict ordering is not really necesssary, and that I could get away with some kind of a partial order, if I new exactly what the btree stuff is looking for)... Dima