1. 程式人生 > >清除SQL Server資料快取和執行計劃快取,檢視執行計劃的各種方式對比

清除SQL Server資料快取和執行計劃快取,檢視執行計劃的各種方式對比

清除資料和執行計劃快取:

DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE

開啟統計資料:

SET STATISTICS IO ON

SET STATISTICS TIME ON

開啟執行計劃:

SET SHOWPLAN_TEXT ON
SET SHOWPLAN_ALL ON
SET STATISTICS PROFILE ON
SET SHOWPLAN_XML ON
SET STATISTICS PROFILE XML

各選項的區別

Command

Execute Query?

Include Estimated Row Counts & Stats

Include Actual Row Counts & Stats

Text Plan

SET SHOWPLAN_TEXT ON

No

No

No

SET SHOWPLAN_ALL ON

No

Yes

No

SET STATISTICS PROFILE ON

Yes

Yes

Yes

XML Plan

SET SHOWPLAN_XML ON

No

Yes

No

SET STATISTICS PROFILE XML

Yes

Yes

Yes