您的位置:首页 > 数据库

简单对比几条查询语句的执行时间

2017-08-25 09:43 316 查看
平时都是用第三种查询,今天看了SQL必知必会 第4版,作了几次查询实验。原来在一般情况下,还是用嵌套查询时间快些: set statistics time on; select * from ICBOMChild where FInterID in (select FInterID from ICBOM where FItemID in (select FItemID from t_ICItem where FNumber like'9.9250.%'))SQL Server 分析和编译时间: CPU 时间 = 13 毫秒,占用时间 = 13 毫秒。
SQL Server 执行时间: CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
(272 行受影响)
SQL Server 执行时间: CPU 时间 = 0 毫秒,占用时间 = 3 毫秒。--------------------------------------------------------------------------------------------------------------------

select * from ICBOMChild t1 join ICBOM t2 on t1.FInterID=t2.FInterID join t_ICItem t3 on t2.FItemID=t3.FItemID and t3.FNumber like '9.9250.%'

SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。

(272 行受影响)

SQL Server 执行时间:
CPU 时间 = 32 毫秒,占用时间 = 395 毫秒。
----------------------------------------------------------------------------------------------------------------------

set statistics time on;
select * from ICBOMChild t1,ICBOM t2,t_ICItem t3 where t1.FInterID=t2.FInterID and t2.FItemID=t3.FItemID and t3.FNumber like '9.9250.%'

SQL Server 分析和编译时间:
CPU 时间 = 31 毫秒,占用时间 = 41 毫秒。

SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。

(272 行受影响)

SQL Server 执行时间:
CPU 时间 = 32 毫秒,占用时间 = 46 毫秒。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mssql