Skip to content

Commit 15f04e9

Browse files
authored
Merge pull request BrentOzarULTD#3805 from ReeceGoding/warn-if-automatic-tuning-non-default
sp_Blitz: warn if Automatic Tuning is in a non-default state (closes BrentOzarULTD#3800)
2 parents 2422c4b + 16f2481 commit 15f04e9

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

‎Documentation/sp_Blitz_Checks_by_Priority.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Before adding a new check, make sure to add a Github issue for it first, and hav
66

77
If you want to change anything about a check - the priority, finding, URL, or ID - open a Github issue first. The relevant scripts have to be updated too.
88

9-
CURRENT HIGH CHECKID: 274.
10-
If you want to add a new one, start at 275.
9+
CURRENT HIGH CHECKID: 275.
10+
If you want to add a new one, start at 276.
1111

1212
| Priority | FindingsGroup | Finding | URL | CheckID |
1313
|----------|-----------------------------|---------------------------------------------------------|------------------------------------------------------------------------|----------|
@@ -278,6 +278,7 @@ If you want to add a new one, start at 275.
278278
| 210 | Non-Default Database Config | Trustworthy Enabled | https://www.BrentOzar.com/go/dbdefaults | 137 |
279279
| 210 | Non-Default Database Config | Broker Enabled | https://www.BrentOzar.com/go/dbdefaults | 230 |
280280
| 210 | Non-Default Database Config | Honor Broker Priority Enabled | https://www.BrentOzar.com/go/dbdefaults | 231 |
281+
| 210 | Non-Default Database Config | Automatic Tuning | https://learn.microsoft.com/en-us/sql/relational-databases/automatic-tuning/automatic-tuning | 275 |
281282
| 210 | Non-Default Database Scoped Config | MAXDOP | https://www.BrentOzar.com/go/dbscope | 194 |
282283
| 210 | Non-Default Database Scoped Config | Legacy CE | https://www.BrentOzar.com/go/dbscope | 195 |
283284
| 210 | Non-Default Database Scoped Config | Parameter Sniffing | https://www.BrentOzar.com/go/dbscope | 196 |

‎sp_Blitz.sql‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8058,6 +8058,41 @@ EXEC dbo.sp_MSforeachdb 'USE [?]; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITT
80588058
OPTION (RECOMPILE);';
80598059
END;
80608060

8061+
/* CheckID 275 - Non-Default Database Config - Automatic Tuning */
8062+
IF NOT EXISTS (
8063+
SELECT 1
8064+
FROM #SkipChecks
8065+
WHERE DatabaseName IS NULL
8066+
AND CheckID = 275
8067+
)
8068+
AND EXISTS (SELECT * FROM sys.all_objects WHERE name = 'database_automatic_tuning_options')
8069+
BEGIN
8070+
IF @Debug IN (1,2)
8071+
BEGIN
8072+
RAISERROR ('Running CheckId [%d].',0,1,275) WITH NOWAIT;
8073+
END
8074+
8075+
EXECUTE sp_MSforeachdb 'USE [?];
8076+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
8077+
INSERT INTO #BlitzResults (CheckID, DatabaseName, Priority, FindingsGroup, Finding, URL, Details)
8078+
SELECT 275 AS CheckID
8079+
,''?'' AS DatabaseName
8080+
,210 AS Priority
8081+
,''Non-Default Database Config'' AS FindingsGroup
8082+
,''Automatic Tuning'' AS Finding
8083+
,''https://learn.microsoft.com/en-us/sql/relational-databases/automatic-tuning/automatic-tuning'' AS URL
8084+
/* Every column in sys.database_automatic_tuning_options is nullable, so we defend against that. */
8085+
,N''Automatic Tuning setting '' + ISNULL(dato.[name], ''unknown'')
8086+
+ '' is configured to '' + ISNULL(dato.desired_state_desc, ''unknown'') + ''.''
8087+
+ '' This database setting is not the default.''
8088+
+ '' The running value is '' + ISNULL(dato.actual_state_desc, ''unknown'') + ''.''
8089+
+ '' See sys.database_automatic_tuning_options for more details.'' AS Details
8090+
FROM sys.database_automatic_tuning_options dato
8091+
WHERE dato.desired_state IS NOT NULL AND dato.desired_state <> 2
8092+
AND ''?'' != ''rdsadmin''
8093+
;';
8094+
END; --of Check 275.
8095+
80618096
/* Check 218 - Show me the dodgy SET Options */
80628097
IF NOT EXISTS (
80638098
SELECT 1
@@ -8107,7 +8142,7 @@ EXEC dbo.sp_MSforeachdb 'USE [?]; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITT
81078142
BEGIN
81088143
IF @Debug IN (1,2)
81098144
BEGIN
8110-
RAISERROR ('Running CheckId [%d].',0,1,218) WITH NOWAIT;
8145+
RAISERROR ('Running CheckId [%d].',0,1,225) WITH NOWAIT;
81118146
END
81128147

81138148
EXECUTE sp_MSforeachdb 'USE [?];

0 commit comments

Comments
 (0)