bor*_*ula 4 sql-server performance sql-server-2005
应该避免哪些SQL Server查询功能/子句的示例?
最近我发现NOT IN子句严重降低了性能.
你有更多的例子吗?
避免的原因NOT IN并不是真正的性能,而是当集合包含null时,它具有非常令人惊讶的行为.例如:
select 1
where 1 not in (2,null)
Run Code Online (Sandbox Code Playgroud)
这不会返回任何行,因为它where被解释为:
where 1 <> 2 and 1 <> null
Run Code Online (Sandbox Code Playgroud)
首先1 <> null评估为未知.然后1 <> 2 and unknown评估为未知.所以你不会收到任何行.
| 归档时间: |
|
| 查看次数: |
469 次 |
| 最近记录: |