Sql server統計查詢語句消耗時間


方法1【set statistic 】:

set statistics time on
go
 xxxx
go
set statistics time off

--適用於第一次查找,下一次查找時,易獲取緩存 導致查詢時間不准確;而且 設置time查找 易受其他因素影響(如系統負載等);

--多次對比查詢  建議設置 IO

set statistics IO on
go
 xxxx
go
set statistics IO off

 

 

方法2【getDate()】:

DECLARE @begin dateTime
DECLARE @end dateTime
SET @begin=getdate();
BEGIN
 xxxx
end
set @end=getdate();
SELECT datediff(ms,@begin,@end) as 'Elapsed Time'

方法3【設置Query-Query options】:

 

后兩種,未實際驗證,見諒。

參考:jcx5083761的專欄  Sql server統計查詢語句消耗時間


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM