[英]SQL Server 2005 - Select Performance - WHERE and NULL
I have the following issue: 我有以下问题:
SQL Server 2005 SQL Server 2005
Query: 查询:
SELECT * FROM Documents WHERE value = 0
CASE A: 案例A:
CASE B: 案例B:
CASE C: 案例C:
Is this a common behavior, or do I have to search the cause of the performance degrees somewhere else ? 这是常见的行为吗?还是我必须在其他地方搜索导致性能降低的原因?
You almost certainly don't have an index on the value
column. 您几乎可以肯定在value
列上没有索引。 Given this assumption, your results aren't very surprising. 在这种假设下,您的结果并不令人惊讶。 NULL
is internally stored as a separate bit that is simpler to lookup (and reject) than performing a numeric comparison. NULL
在内部存储为单独的位,比执行数字比较更容易查找(和拒绝)。
If you had an index, then I'd be somewhat suprised by these results. 如果您有索引,那么这些结果会让我有些惊讶。 It would also help if you posted exact figures about the table (column widths), as well as exactly what results you saw instead of "X, Y and Z". 如果您发布有关表格的准确数字(列宽),以及确切看到的结果而不是“ X,Y和Z”,这也将有所帮助。 And as always, when checking for performance issues look at the query plan . 与往常一样,在检查性能问题时,请查看查询计划 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.