Re: bit operations - Mailing list pgsql-general

From merlyn@stonehenge.com (Randal L. Schwartz)
Subject Re: bit operations
Date
Msg-id m1bsmsjudh.fsf@halfdome.holdit.com
Whole thread Raw
In response to Re: bit operations  (Oliver Vecernik <vecernik@aon.at>)
List pgsql-general
>>>>> "Oliver" == Oliver Vecernik <vecernik@aon.at> writes:

Oliver> "Randal L. Schwartz" wrote:
>>
>> >>>>> "Oliver" == Oliver Vecernik <vecernik@aon.at> writes:
>>
>> >> Say I wanna check if 8 (1xxx) and 2 (xx1x) is set, how do I do that?!
>>
Oliver> Sorry, I didn't read the whole question first:
>>
Oliver> select * from table where ((flags & 8) <> 0) and ((flags & 2) <> 0);
>>
>> In the old days, we spelled that as flags & 10 = 10. :)  Wouldn't that
>> work just as well?

Oliver> As far as I know testing for <> 0 could be calculated faster. Does
Oliver> anybody know if this is true?

But that's wrong for flags & 10.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

pgsql-general by date:

Previous
From: Robert Berger
Date:
Subject: Re: Re: query optimizer questions
Next
From: Taral
Date:
Subject: Toast question