In a where
clause, if the first condition is FALSE, then the second condition is checked in SQL Server?
For example
select *
from users
where (condition 1) AND (condition 2)
If condition 1 is False, will condition 2 be checked?
It is non-deterministic. You cannot rely on order of evaluation.
SQL Server query optimizer is responsible for parsing T-SQL query and creating execution plan based on table sizes, indexes, etc. So same T-SQL statement against same database schema might be executed differently depending on database content, configuration, etc.
Query optimizer prioritizes speed of execution and is able to parallelise execution of a single T-SQL statement. It is highly unlikely that execution of filter clauses ends up being executed one after another.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With