Skip to content

Commit 083149b

Browse files
authored
Merge pull request #2945 from erikdarlingdata/issue_2938
add target recovery interval check
2 parents fb5e8ff + 9bba9e5 commit 083149b

File tree

2 files changed

+80
-6
lines changed

2 files changed

+80
-6
lines changed

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: 256.
10-
If you want to add a new one, start at 257.
9+
CURRENT HIGH CHECKID: 257.
10+
If you want to add a new one, start at 258.
1111

1212
| Priority | FindingsGroup | Finding | URL | CheckID |
1313
|----------|-----------------------------|---------------------------------------------------------|------------------------------------------------------------------------|----------|
@@ -61,6 +61,7 @@ If you want to add a new one, start at 257.
6161
| 50 | Performance | Poison Wait Detected | https://www.BrentOzar.com/go/poison | 107 |
6262
| 50 | Performance | Poison Wait Detected: CMEMTHREAD & NUMA | https://www.BrentOzar.com/go/poison | 162 |
6363
| 50 | Performance | Poison Wait Detected: Serializable Locking | https://www.BrentOzar.com/go/serializable | 121 |
64+
| 50 | Performance | Recovery Interval Not Optimal| https://sqlperformance.com/2020/05/system-configuration/0-to-60-switching-to-indirect-checkpoints | 257 |
6465
| 50 | Performance | Snapshotting Too Many Databases | https://www.BrentOzar.com/go/toomanysnaps | 236 |
6566
| 50 | Performance | Too Much Free Memory | https://www.BrentOzar.com/go/freememory | 165 |
6667
| 50 | Performance | Wait Stats Cleared Recently| | 205 |

sp_Blitz.sql

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4312,10 +4312,10 @@ AS
43124312
SELECT 'containment', 0, 141, 210, 'Containment Enabled', 'https://www.brentozar.com/go/dbdefaults', NULL
43134313
FROM sys.all_columns
43144314
WHERE name = 'containment' AND object_id = OBJECT_ID('sys.databases');
4315-
INSERT INTO #DatabaseDefaults
4316-
SELECT 'target_recovery_time_in_seconds', 0, 142, 210, 'Target Recovery Time Changed', 'https://www.brentozar.com/go/dbdefaults', NULL
4317-
FROM sys.all_columns
4318-
WHERE name = 'target_recovery_time_in_seconds' AND object_id = OBJECT_ID('sys.databases');
4315+
--INSERT INTO #DatabaseDefaults
4316+
-- SELECT 'target_recovery_time_in_seconds', 0, 142, 210, 'Target Recovery Time Changed', 'https://www.brentozar.com/go/dbdefaults', NULL
4317+
-- FROM sys.all_columns
4318+
-- WHERE name = 'target_recovery_time_in_seconds' AND object_id = OBJECT_ID('sys.databases');
43194319
INSERT INTO #DatabaseDefaults
43204320
SELECT 'delayed_durability', 0, 143, 210, 'Delayed Durability Enabled', 'https://www.brentozar.com/go/dbdefaults', NULL
43214321
FROM sys.all_columns
@@ -4359,6 +4359,79 @@ AS
43594359

43604360
CLOSE DatabaseDefaultsLoop;
43614361
DEALLOCATE DatabaseDefaultsLoop;
4362+
4363+
/* Check if target recovery interval <> 60 */
4364+
IF
4365+
@ProductVersionMajor >= 10
4366+
AND NOT EXISTS
4367+
(
4368+
SELECT
4369+
1/0
4370+
FROM #SkipChecks AS sc
4371+
WHERE sc.DatabaseName IS NULL
4372+
AND sc.CheckID = 257
4373+
)
4374+
BEGIN
4375+
IF EXISTS
4376+
(
4377+
SELECT
4378+
1/0
4379+
FROM sys.all_columns AS ac
4380+
WHERE ac.name = 'target_recovery_time_in_seconds'
4381+
AND ac.object_id = OBJECT_ID('sys.databases')
4382+
)
4383+
BEGIN
4384+
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 257) WITH NOWAIT;
4385+
4386+
DECLARE
4387+
@tri nvarchar(max) = N'
4388+
SELECT
4389+
DatabaseName =
4390+
d.name,
4391+
CheckId =
4392+
257,
4393+
Priority =
4394+
50,
4395+
FindingsGroup =
4396+
N''Performance'',
4397+
Finding =
4398+
N''Recovery Interval Not Optimal'',
4399+
URL =
4400+
N''https://sqlperformance.com/2020/05/system-configuration/0-to-60-switching-to-indirect-checkpoints'',
4401+
Details =
4402+
N''The database '' +
4403+
QUOTENAME(d.name) +
4404+
N'' has a target recovery interval of '' +
4405+
RTRIM(d.target_recovery_time_in_seconds) +
4406+
CASE
4407+
WHEN d.target_recovery_time_in_seconds = 0
4408+
THEN N'', which is a legacy default, and should be changed to 60.''
4409+
WHEN d.target_recovery_time_in_seconds <> 0
4410+
THEN N'', which is probably a mistake, and should be changed to 60.''
4411+
END
4412+
FROM sys.databases AS d
4413+
WHERE d.database_id > 4
4414+
AND d.is_read_only = 0
4415+
AND d.is_in_standby = 0
4416+
AND d.target_recovery_time_in_seconds <> 60;
4417+
';
4418+
4419+
INSERT INTO
4420+
#BlitzResults
4421+
(
4422+
DatabaseName,
4423+
CheckID,
4424+
Priority,
4425+
FindingsGroup,
4426+
Finding,
4427+
URL,
4428+
Details
4429+
)
4430+
EXEC sys.sp_executesql
4431+
@tri;
4432+
4433+
END;
4434+
END;
43624435

43634436

43644437
/*This checks to see if Agent is Offline*/

0 commit comments

Comments
 (0)