2012 資料庫引擎的執行緒計數
SQL Server 通常會針對每個查詢要求開啟系統執行緒,但是如果執行緒數量超過指定的 max worker threads 值,SQL Server 就會共用工作者執行緒。當所有的工作者執行緒都在進行長時間執行的查詢時,SQL Server 可能會反應遲緩,直到工作者執行緒完成並恢復為可用狀態為止。雖然這不算是瑕疵,但有時卻讓人困擾。此監視器會分析可用執行緒數量,如果數量過低,就會發出通知。
工作量增加導致使用的執行緒增加,這可能表示 SQL Server 正在處理大量負載,或者平行執行的查詢數目過多。
調整 max worker threads 是進階選項,只有有經驗的資料庫管理員或通過認證的 SQL Server 技術人員才可變更。
當大量用戶端連接到伺服器時,執行緒集區有助於最佳化效能。通常,會針對每一個查詢要求建立個別的作業系統執行緒。然而,在數以百計的伺服器連接之下,若每個查詢要求都使用一個執行緒,反而會耗用大量的系統資源。max worker threads 選項可讓 SQL Server 建立工作者執行緒集區,以服務更多的查詢要求數量,進而改善效能。
設定 max worker threads 伺服器組態選項
http://go.microsoft.com/fwlink/?LinkId=789186
名稱 | 描述 | 預設值 |
警示優先程式 | 定義警示優先順序。 | 一般 |
警示嚴重性 | 定義警示嚴重性。 | 錯誤 |
快取到期時間 | 指定工作流程所能使用之快取資訊的留存時間上限。可以省略。 | 43200 |
已啟用 | 啟用或停用該工作流程。 | 是 |
產生警示 | 定義工作流程是否會產生警示。 | 是 |
間隔 (秒) | 執行工作流程的週期性時間間隔 (秒)。 | 300 |
可用執行緒計數下限 | 資料來源會判斷每個資料庫引擎處理序的臨界值與執行緒計數,如果臨界值減去目前的執行緒計數小於或等於可用的執行緒計數,就會產生警示 | 10 |
範例數 | 與臨界值比較前平均的範例數 | 6 |
同步處理時間 | 使用 24 小時制指定的同步處理時間。可以予以省略。 | 00:06 |
逾時 (秒) | 指定工作流程在關閉並標記為失敗前所能執行的時間。 | 200 |
Target | Microsoft.SQLServer.2012.DBEngine | ||
Parent Monitor | System.Health.PerformanceState | ||
Category | PerformanceHealth | ||
Enabled | True | ||
Alert Generate | True | ||
Alert Severity | Error | ||
Alert Priority | Normal | ||
Alert Auto Resolve | True | ||
Monitor Type | Microsoft.SQLServer.2012.DBEngine.ThreadCount.MonitorType | ||
Remotable | True | ||
Accessibility | Public | ||
Alert Message |
| ||
RunAs | Default |
<UnitMonitor ID="Microsoft.SQLServer.2012.DBEngine.ThreadCountMonitor" Accessibility="Public" Enabled="true" Target="SQL2012Core!Microsoft.SQLServer.2012.DBEngine" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2012.DBEngine.ThreadCount.MonitorType" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2012.DBEngine.ThreadCountMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL!Microsoft.SQLServer.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="Error"/>
</OperationalStates>
<Configuration>
<ServiceName>$Target/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ServiceName$</ServiceName>
<IntervalSeconds>300</IntervalSeconds>
<TimeoutSeconds>200</TimeoutSeconds>
<MinFreeThreadsCount>10</MinFreeThreadsCount>
<NumSamples>6</NumSamples>
<SyncTime/>
<CacheExpirationTime>43200</CacheExpirationTime>
</Configuration>
</UnitMonitor>