If the first condition is FALSE then the second condition is checked in SQL Server?(如果第一个条件为 FALSE,则在 SQL Server 中检查第二个条件?)
问题描述
在 where 子句中,如果第一个条件为 FALSE,那么在 SQL Server 中检查第二个条件?
In a where clause, if the first condition is FALSE, then the second condition is checked in SQL Server?
例如
select *
from users
where (condition 1) AND (condition 2)
如果条件 1 为 False,是否会检查条件 2?
If condition 1 is False, will condition 2 be checked?
推荐答案
它是不确定的.您不能依赖评估顺序.
It is non-deterministic. You cannot rely on order of evaluation.
SQL Server 查询优化器负责解析 T-SQL 查询并根据表大小、索引等创建执行计划.因此,针对相同数据库架构的相同 T-SQL 语句可能会根据数据库内容、配置等执行不同的操作.
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.
查询优化器优先考虑执行速度,并能够并行执行单个 T-SQL 语句.过滤子句的执行最终一个接一个执行的可能性很小.
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.
这篇关于如果第一个条件为 FALSE,则在 SQL Server 中检查第二个条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如果第一个条件为 FALSE,则在 SQL Server 中检查第
基础教程推荐
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 无法解决整理冲突 2021-01-01
