I am implementing a bitwise filter using SQL, and I want to see if the following optimization is always valid in all cases, and I'm not sure how to prove it. My goal is to limit the number of rows that get compared.
Standard filter pseudo-sql:
IF (A & B = A) // SHOW VALUE
The question is, will it work to add this? :
IF (A = B) OR (A & B = A) WHERE (B >= A) // SHOW VALUE
It seems to me that B must always be >= to A - is there a case where this is not true?
I realize that the above code is still not optimal, I just want to know if this is a viable direction to go in.
Does someone have some amazing maths to help me?