更新时间:2023-09-23 11:51:52
简短的回答是 - 否长答案是 - 绝对不会
The short answer is - no The long answer is - absolutely not
它是否优化了 LIKE('%%') 查询,因为它意味着没有什么可比较的?
Does it optimize LIKE('%%') query since it means there is nothing to compare?
该陈述不真实,因为有可以比较的东西.以下是等价的
The statement is untrue, because there is something to compare. The following are equivalent
WHERE column LIKE '%%'
WHERE column IS NOT NULL
IS NOT NULL 需要进行表扫描,除非该列中的非空值很少并且索引良好.
IS NOT NULL requires a table scan, unless there are very few non-null values in the column and it is well indexed.
有关 SQL Server 中动态搜索过程的资源:
您只需必须阅读 SQL Server MVP Erland Sommarskog 的这篇文章http://www.sommarskog.se/dyn-search.html(选择您的版本,或同时阅读)
Resource on Dynamic Search procedures in SQL Server:
You simply must read this article by Erland Sommarskog, SQL Server MVP http://www.sommarskog.se/dyn-search.html (pick your version, or read both)
否则,如果您需要 CONTAINS 样式搜索的良好性能,请考虑使用 SQL Server 全文引擎.
Otherwise if you need good performance on CONTAINS style searches, consider using SQL Server Fulltext engine.