This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update logic to include TempDB check ✅
- Loading branch information
1 parent
9425ec3
commit 46e6b3c
Showing
1 changed file
with
10 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ Usage: | |
2. Review the results and execute the generated script if the recommended settings are acceptable. | ||
Revision History: | ||
2023-11-13: Added ability to check TempDB file count - Blake Drumm ([email protected]) | ||
2023-10-31: Fixed the MaxDOP Calculation - Blake Drumm ([email protected]) | ||
2023-10-30: Script created by Blake Drumm ([email protected]) | ||
|
@@ -32,6 +33,8 @@ DECLARE @NumaNodes INT, | |
@MaxDop INT, | ||
@RecommendedMaxDop INT, | ||
@CostThreshold INT, | ||
@TempDBFileCount INT, | ||
@RecommendedTempDBFileCount INT, | ||
@ChangeScript NVARCHAR(MAX) = '', | ||
@ShowAdvancedOptions INT; | ||
|
||
|
@@ -41,6 +44,10 @@ SELECT @NumCPUs = cpu_count FROM sys.dm_os_sys_info; | |
SELECT @MaxDop = CAST(value_in_use AS INT) FROM sys.configurations WHERE name = 'max degree of parallelism'; | ||
SELECT @CostThreshold = CAST(value_in_use AS INT) FROM sys.configurations WHERE name = 'cost threshold for parallelism'; | ||
SELECT @ShowAdvancedOptions = CAST(value_in_use AS INT) FROM sys.configurations WHERE name = 'show advanced options'; | ||
SELECT @TempDBFileCount = COUNT(*) FROM sys.master_files WHERE database_id = 2 AND type_desc = 'ROWS'; | ||
|
||
-- Recommended TempDB File Count Calculation | ||
SET @RecommendedTempDBFileCount = IIF(@NumCPUs <= 8, @NumCPUs, 8); | ||
|
||
-- MAXDOP Calculation | ||
IF @NumaNodes = 1 | ||
|
@@ -68,7 +75,9 @@ INSERT INTO @Results (Description, Value) | |
VALUES ('MAXDOP Configured Value', CAST(@MaxDop AS VARCHAR)), | ||
('MAXDOP Recommended Value', CAST(@RecommendedMaxDop AS VARCHAR)), | ||
('Cost Threshold Configured Value', CAST(@CostThreshold AS VARCHAR)), | ||
('Generally Recommended Cost Threshold', '40-50'); | ||
('Generally Recommended Cost Threshold', '40-50'), | ||
('TempDB File Count', CAST(@TempDBFileCount AS VARCHAR)), | ||
('TempDB Recommended File Count', CAST(@RecommendedTempDBFileCount AS VARCHAR)); | ||
|
||
-- Check and build ChangeScript for other settings | ||
IF @MaxDop <> @RecommendedMaxDop | ||
|