sup*_*erM 1 exists count sql-server-2008
我有一个表,想要检查是否存在满足某些简单条件的记录.我想知道哪个会更快:
if (select count(*) from ... where ...) > 0
要么
if exists (select top (1) from ... where ...) .
if exists (select top (1) from ... where ...)
rt2*_*800 5
只要找到匹配where子句的记录,exists就会返回结果,而count需要扫描整个表来确定计数.所以存在更快
归档时间:
13 年,9 月 前
查看次数:
1025 次
最近记录: