有一台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资源.
参考资料:
https://msdn.microsoft.com/zh-cn/library/ms177526.aspx
http://www.sqlserver-dba.com/cpu/
如果你真心觉得文章写得不错,而且对你有所帮助,那就不妨小小打赏一下吧,如果囊中羞涩,不妨帮忙“推荐"一下,您的“推荐”和”打赏“将是我最大的写作动力!
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.