Last active
June 22, 2021 21:35
-
-
Save danilocbraga/57e98516b6d063644c621ab0d7bfe122 to your computer and use it in GitHub Desktop.
Recommend MaxDop settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @hyperthreadingRatio bit | |
declare @logicalCPUs int | |
declare @HTEnabled int | |
declare @physicalCPU int | |
declare @SOCKET int | |
declare @logicalCPUPerNuma int | |
declare @NoOfNUMA int | |
select @logicalCPUs = cpu_count -- [Logical CPU Count] | |
,@hyperthreadingRatio = hyperthread_ratio -- [Hyperthread Ratio] | |
,@physicalCPU = cpu_count / hyperthread_ratio -- [Physical CPU Count] | |
,@HTEnabled = case | |
when cpu_count > hyperthread_ratio | |
then 1 | |
else 0 | |
end -- HTEnabledfrom sys.dm_os_sys_info | |
option (recompile); | |
select @logicalCPUPerNuma = COUNT(parent_node_id) -- [NumberOfLogicalProcessorsPerNuma] | |
from sys.dm_os_schedulers | |
where [status] = 'VISIBLE ONLINE' | |
and parent_node_id < 64group by parent_node_id | |
option (recompile); | |
select @NoOfNUMA = count(distinct parent_node_id) | |
from sys.dm_os_schedulers -- find NO OF NUMA Nodes | |
where [status] = 'VISIBLE ONLINE' | |
and parent_node_id < 64 | |
-- Report the recommendations ....select | |
--- 8 or less processors and NO HT enabled | |
case | |
when @logicalCPUs < 8 | |
and @HTEnabled = 0 | |
then 'MAXDOP setting should be : ' + CAST(@logicalCPUs as varchar(3)) | |
--- 8 or more processors and NO HT enabled | |
when @logicalCPUs >= 8 | |
and @HTEnabled = 0 | |
then 'MAXDOP setting should be : 8' | |
--- 8 or more processors and HT enabled and NO NUMA | |
when @logicalCPUs >= 8 | |
and @HTEnabled = 1 | |
and @NoofNUMA = 1 | |
then 'MaxDop setting should be : ' + CAST(@logicalCPUPerNuma / @physicalCPU as varchar(3)) | |
--- 8 or more processors and HT enabled and NUMA | |
when @logicalCPUs >= 8 | |
and @HTEnabled = 1 | |
and @NoofNUMA > 1 | |
then 'MaxDop setting should be : ' + CAST(@logicalCPUPerNuma / @physicalCPU as varchar(3)) | |
else '' | |
end as Recommendations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of copying directly without any attributes, you should mention the source and link it https://dba.stackexchange.com/a/36578/8783