Skip to content

Instantly share code, notes, and snippets.

@Otterpohl
Created May 13, 2022 16:23
Show Gist options
  • Save Otterpohl/527d8037cacd2d9cc25a9a1d583cc8ed to your computer and use it in GitHub Desktop.
Save Otterpohl/527d8037cacd2d9cc25a9a1d583cc8ed to your computer and use it in GitHub Desktop.
Set MaxDOP to match number of cores
EXEC sys.sp_configure N'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO
DECLARE @DOP INT
SELECT @DOP = CASE
WHEN cpu_count > 16 THEN 8
else cpu_count / 2
END
FROM sys.dm_os_sys_info
EXEC sys.sp_configure N'max degree of parallelism', @DOP
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sys.sp_configure N'show advanced options', 0
GO
RECONFIGURE WITH OVERRIDE
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment