有一台SQL Server(SQL Server 2014 標准版)服務器中的scheduler_count與cpu_count不一致,如下截圖所示:
SELECT cpu_count ,
scheduler_count
FROM sys.dm_os_sys_info;
SQL Server中Scheduler數量應該與邏輯CPU的核數一致,而sys.dm_os_sys_info中的scheduler_count 為8,少於cpu_count的12個數量,那么很有可能,有一些Scheduler的狀態為VISIBLE ONLINE.下面摘自Healthy SQL: A Comprehensive Guide to Healthy SQL Server Performance
SELECT is_online
,[status]
, COUNT(*) AS [count]
FROM sys.dm_os_schedulers
WHERE scheduler_id < 255
GROUP BY is_online,
[status];
官方文檔https://msdn.microsoft.com/en-us/library/ms177526.aspx關於Status的介紹如下:
Indicates the status of the scheduler. Can be one of the following values:
- HIDDEN ONLINE
- HIDDEN OFFLINE
- VISIBLE ONLINE
- VISIBLE OFFLINE
- VISIBLE ONLINE (DAC)
- HOT_ADDED
Is not nullable.
HIDDEN schedulers are used to process requests that are internal to the Database Engine. VISIBLE schedulers are used to process user requests.
OFFLINE schedulers map to processors that are offline in the affinity mask and are, therefore, not being used to process any requests. ONLINE schedulers map to processors that are online in the affinity mask and are available to process threads.
DAC indicates the scheduler is running under a dedicated administrator connection.
HOT ADDED indicates the schedulers were added in response to a hot add CPU event.
其中關於OFFLINE與ONLINE的解釋:OFFLINE 計划程序在關聯掩碼中映射到處於脫機狀態的處理器,因此不用於處理任何請求。 ONLINE 計划程序在關聯掩碼中映射到處於聯機狀態的處理器,並且可用於處理線程。
基本上,調度程序(SQL Schedulers)不會用於查詢處理。 這種情況是由關聯掩蔽或許可限制引起的:
When SQL Server uses a portion of the server processors , the is_online column on the sys.dm_os_schedulers will return 0.
Basically , the scheduler will not be used for query processing. The situation is caused by either affinity masking or licensing restrictions
Be careful if you attempt to change these number – either be confident you know how to use affinity masking or if Virtualization is used , speak to the VM administrator about apportioning more cores per virtual socket. In either case analyse the impact and test thoroughly
檢查服務器的CPU資源使用情況,發現在Resource Monitor里面,有些邏輯CPU上利用率幾乎為零。基本上就可以判定是SQL License許可限制的可能性最大
檢查官方文檔SQL Server 2014 各個版本支持的功能發現標准版單個實例使用的最大計算能力(SQL Server 數據庫引擎)限制為4個插槽或16核,取兩者中最小值。如下截圖所示
檢查服務器的CPU配置,發現CPU資源配置如下:12核是(虛擬插槽數6*每個插槽的內核數為2)也就是說6*2=12 ,超出了License限制(4個插槽數),所以應該調整為4(虛擬插槽數)*3(內核數)才能有效的利用分配到CPU資源.
參考資料: