SQL 重新編譯

Microsoft.SQLServer.2016.DBEngine.SQLReCompilationMonitor (UnitMonitor)

2016 資料庫引擎的 SQL Re-Compilation。附註: 預設會停用此監視器。必要時請使用覆寫加以啟用。

Knowledge Base article:

摘要

SQL 2016 資料庫引擎的 SQL Re-Compilation 監視器

資料庫的特定變更可能會導致執行計畫沒有效率或無效,端視資料庫的新狀態而定。SQL Server 會偵測讓執行計畫失效的變更並將該計畫標示為無效。然後系統會根據執行查詢的下一個連接,重新編譯新的計畫。

原因

重新編譯比編譯的次數要高。

解決方式

啟動 SQL Profiler 並檢查 SQL:StmtRecompile 追蹤以識別問題的根本原因。

可覆寫的參數

名稱

描述

預設值

警示優先程式

定義警示優先順序。

一般

警示嚴重性

定義警示嚴重性。

警告

已啟用

啟用或停用該工作流程。

產生警示

定義工作流程是否會產生警示。

間隔 (秒)

執行工作流程的週期性時間間隔 (秒)。

300

範例數

指出測量值在違反臨界值多少次之後,才會變更狀態。

6

同步處理時間

使用 24 小時制指定的同步處理時間。將會忽略。

00:21

臨界值

如果 SQL 重新編譯與 SQL 編譯之間的比率大於此臨界值,就會產生警示

25

逾時 (秒)

指定允許工作流程在關閉且標示為失敗之前執行的時間。

200

Element properties:

TargetMicrosoft.SQLServer.2016.DBEngine
Parent MonitorSystem.Health.PerformanceState
CategoryPerformanceHealth
EnabledFalse
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2016.DBEngine.SQLReCompilation.MonitorType
RemotableTrue
AccessibilityPublic
Alert Message
MSSQL 2016: SQL Re-Compilation 太高
電腦 "{1}" 上 SQL 執行個體 "{0}" 的「SQL 重新編譯」太高。請參閱 [警示內容] 索引標籤,以取得詳細資料。
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2016.DBEngine.SQLReCompilationMonitor" Accessibility="Public" Enabled="false" Target="SQL2016Core!Microsoft.SQLServer.2016.DBEngine" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2016.DBEngine.SQLReCompilation.MonitorType" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2016.DBEngine.SQLReCompilationMonitor.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.ServerRole"]/InstanceName$</AlertParameter1>
<AlertParameter2>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Normal" MonitorTypeStateID="Normal" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>300</IntervalSeconds>
<TimeoutSeconds>200</TimeoutSeconds>
<Threshold>25</Threshold>
<NumSamples>6</NumSamples>
<SyncTime/>
</Configuration>
</UnitMonitor>