Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. DECLARE @CoreCount int;
  2. DECLARE @NumaNodes int;
  3.  
  4. SET @CoreCount = (SELECT i.cpu_count from sys.dm_os_sys_info i);
  5. SET @NumaNodes = (
  6. SELECT MAX(c.memory_node_id) + 1
  7. FROM sys.dm_os_memory_clerks c
  8. WHERE memory_node_id < 64
  9. );
  10.  
  11. IF @CoreCount > 4 /* If less than 5 cores, don't bother. */
  12. BEGIN
  13. DECLARE @MaxDOP int;
  14.  
  15. /* 3/4 of Total Cores in Machine */
  16. SET @MaxDOP = @CoreCount * 0.75;
  17.  
  18. /* if @MaxDOP is greater than the per NUMA node
  19. Core Count, set @MaxDOP = per NUMA node core count
  20. */
  21. IF @MaxDOP > (@CoreCount / @NumaNodes)
  22. SET @MaxDOP = (@CoreCount / @NumaNodes) * 0.75;
  23.  
  24. /*
  25. Reduce @MaxDOP to an even number
  26. */
  27. SET @MaxDOP = @MaxDOP - (@MaxDOP % 2);
  28.  
  29. /* Cap MAXDOP at 8, according to Microsoft */
  30. IF @MaxDOP > 8 SET @MaxDOP = 8;
  31.  
  32. PRINT 'Suggested MAXDOP = ' + CAST(@MaxDOP as varchar(max));
  33. END
  34. ELSE
  35. BEGIN
  36. PRINT 'Suggested MAXDOP = 0 since you have less than 4 cores total.';
  37. PRINT 'This is the default setting, you likely do not need to do';
  38. PRINT 'anything.';
  39. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement