So, do you rely on the short-circuited semantics of Boolean expressions to trigger the IS NULL condition? This seems to work.
One interesting point is that a constant expression of type 1 = 0 , which had no parameters, should be taken into account by the query optimizer. In this case, since the optimizer does not know whether the expression is true or false until runtime, this means that it cannot exclude it. It should evaluate the expression for each line.
Thus, it can be assumed that this will add a negligible cost to the query as to what it will cost if you used a non-parameterized constant expression.
Then combining with OR with the expression IS NULL can also have consequences for the optimizer. He may decide that he cannot benefit from the index on deleted_on , while in a simpler expression he will have. It depends on the RDBMS implementation you use and the distribution of values ββin your database.
Bill karwin
source share