From 9284338f9a19733bf71858aaeb04210a8ed7ec73 Mon Sep 17 00:00:00 2001 From: Brent Ozar Date: Mon, 17 Nov 2025 04:50:14 -0800 Subject: [PATCH] #3741 sp_Blitz optimized locking Warn if optimized locking is enabled but RCSI is not. Closes #3741. --- Documentation/sp_Blitz_Checks_by_Priority.md | 5 ++-- sp_Blitz.sql | 29 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Documentation/sp_Blitz_Checks_by_Priority.md b/Documentation/sp_Blitz_Checks_by_Priority.md index af9d6c66..950d11b8 100644 --- a/Documentation/sp_Blitz_Checks_by_Priority.md +++ b/Documentation/sp_Blitz_Checks_by_Priority.md @@ -6,8 +6,8 @@ Before adding a new check, make sure to add a Github issue for it first, and hav 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. -CURRENT HIGH CHECKID: 271. -If you want to add a new one, start at 272. +CURRENT HIGH CHECKID: 272. +If you want to add a new one, start at 273. | Priority | FindingsGroup | Finding | URL | CheckID | |----------|-----------------------------|---------------------------------------------------------|------------------------------------------------------------------------|----------| @@ -87,6 +87,7 @@ If you want to add a new one, start at 272. | 100 | Performance | Many Plans for One Query | https://www.BrentOzar.com/go/parameterization | 160 | | 100 | Performance | Max Memory Set Too High | https://www.BrentOzar.com/go/max | 50 | | 100 | Performance | Memory Pressure Affecting Queries | https://www.BrentOzar.com/go/grants | 117 | +| 100 | Performance | Optimized Locking Not Fully Set Up | https://www.BrentOzar.com/go/optimizedlocking | 272 | | 100 | Performance | Partitioned database with non-aligned indexes | https://www.BrentOzar.com/go/aligned | 72 | | 100 | Performance | Repetitive Maintenance Tasks | https://ola.hallengren.com | 181 | | 100 | Performance | Resource Governor Enabled | https://www.BrentOzar.com/go/rg | 10 | diff --git a/sp_Blitz.sql b/sp_Blitz.sql index 9f88d7ae..928f486a 100644 --- a/sp_Blitz.sql +++ b/sp_Blitz.sql @@ -4935,6 +4935,35 @@ AS CLOSE DatabaseDefaultsLoop; DEALLOCATE DatabaseDefaultsLoop; +/* CheckID 272 - Performance - Optimized Locking Not Fully Set Up */ +IF EXISTS (SELECT * FROM sys.all_columns WHERE name = 'is_optimized_locking_on' AND object_id = OBJECT_ID('sys.databases')) + AND NOT EXISTS ( SELECT 1 + FROM #SkipChecks + WHERE DatabaseName IS NULL AND CheckID = 272 ) + BEGIN + IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 272) WITH NOWAIT; + + INSERT INTO [#BlitzResults] + ( [CheckID] , + [Priority] , + [FindingsGroup] , + [Finding] , + [DatabaseName] , + [URL] , + [Details] ) + + SELECT + 272 AS [CheckID] , + 100 AS [Priority] , + 'Performance' AS [FindingsGroup] , + 'Optimized Locking Not Fully Set Up' AS [Finding] , + name, + 'https://www.brentozar.com/go/optimizedlocking' AS [URL] , + 'RCSI should be enabled on this database to get the full benefits of optimized locking.' AS [Details] + FROM sys.databases + WHERE is_optimized_locking_on = 1 AND is_read_committed_snapshot_on = 0; + END; + /* Check if target recovery interval <> 60 */ IF @ProductVersionMajor >= 10