From 46e6b3c244b50963cfdb5db7ce3e780ecdf0dea2 Mon Sep 17 00:00:00 2001 From: Blake Drumm Date: Mon, 13 Nov 2023 14:21:52 -0500 Subject: [PATCH] Update logic to include TempDB check :white_check_mark: --- SQL Queries/maxdop_calculator.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/SQL Queries/maxdop_calculator.sql b/SQL Queries/maxdop_calculator.sql index d89e46f..dd23bdc 100644 --- a/SQL Queries/maxdop_calculator.sql +++ b/SQL Queries/maxdop_calculator.sql @@ -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 (blakedrumm@microsoft.com) 2023-10-31: Fixed the MaxDOP Calculation - Blake Drumm (blakedrumm@microsoft.com) 2023-10-30: Script created by Blake Drumm (blakedrumm@microsoft.com) @@ -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