天天看點

檢視sql的執行效率

一、顯示的資訊比較全

SET STATISTICS io ON

        SET STATISTICS time ON

        go

  ---你要測試的sql語句

select g.grpName,t.grpID,t.flowID,t.typeName,t.description

from hyGroup g  ,hyType t where  t.grpID = g.flowID      

        go

        SET STATISTICS profile OFF

        SET STATISTICS io OFF

        SET STATISTICS time OFF

二、隻顯示執行時間

declare @d datetime set @d=getdate()

  ---你要測試的sql語句

select * from tablename

select[語句執行花費時間(毫秒)]=datediff(ms,@d,getdate())