Skip to content

Commit 126bb62

Browse files
2 parents 7261672 + bcfea44 commit 126bb62

File tree

5 files changed

+118
-51
lines changed

5 files changed

+118
-51
lines changed

Deprecated/readme.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
These old versions worked on SQL Server 2005.
1+
sp_AllNightLog, sp_AllNightLog_Setup, sp_BlitzInMemoryOLTP, and sp_BlitzQueryStore are no longer maintained. They may still work, but no guarantees. Please don't submit issues or pull requests to change them. You're welcome to fork the code and build your own supported version, of course, since they're open source.
22

3-
They are no longer maintained or updated.
4-
5-
Don't use 'em on SQL Server 2008 or newer - these are only for folks who still
6-
need to manage SQL Server 2005.
3+
The other files in this folder are older versions of the First Responder Kit that work with versions of Microsoft SQL Server that Microsoft themselves no longer support. If you're cursed enough to work with antiques like SQL Server 2012, 2008, or heaven forbid, 2005, you may still be able to get value out of these, but we don't support the scripts anymore either.

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

1212
| Priority | FindingsGroup | Finding | URL | CheckID |
1313
|----------|-----------------------------|---------------------------------------------------------|------------------------------------------------------------------------|----------|
@@ -247,6 +247,7 @@ If you want to add a new one, start at 262.
247247
| 200 | Performance | Non-Dynamic Memory | https://www.BrentOzar.com/go/memory | 190 |
248248
| 200 | Performance | Old Compatibility Level | https://www.BrentOzar.com/go/compatlevel | 62 |
249249
| 200 | Performance | Query Store Disabled | https://www.BrentOzar.com/go/querystore | 163 |
250+
| 200 | Performance | Query Store Wait Stats Disabled | https://www.sqlskills.com/blogs/erin/query-store-settings/ | 262 |
250251
| 200 | Performance | Snapshot Backups Occurring | https://www.BrentOzar.com/go/snaps | 178 |
251252
| 200 | Performance | User-Created Statistics In Place | https://www.BrentOzar.com/go/userstats | 122 |
252253
| 200 | Performance | SSAS/SSIS/SSRS Installed | https://www.BrentOzar.com/go/services | 224 |

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Navigation
2525
- [sp_BlitzAnalysis: Query sp_BlitzFirst output tables](#sp_blitzanalysis-query-sp_BlitzFirst-output-tables)
2626
- Backups and Restores:
2727
- [sp_BlitzBackups: How Much Data Could You Lose](#sp_blitzbackups-how-much-data-could-you-lose)
28-
- [sp_AllNightLog: Back Up Faster to Lose Less Data](#sp_allnightlog-back-up-faster-to-lose-less-data)
2928
- [sp_DatabaseRestore: Easier Multi-File Restores](#sp_databaserestore-easier-multi-file-restores)
3029
- [Parameters Common to Many of the Stored Procedures](#parameters-common-to-many-of-the-stored-procedures)
3130
- [License MIT](#license)
@@ -42,7 +41,7 @@ To install, [download the latest release ZIP](https://github.com/BrentOzarULTD/S
4241
The First Responder Kit runs on:
4342

4443
* SQL Server on Windows - all versions that Microsoft supports. For end of support dates, check out the "Support Ends" column at https://sqlserverupdates.com.
45-
* SQL Server on Linux - yes, fully supported except sp_AllNightLog and sp_DatabaseRestore, which require xp_cmdshell, which Microsoft doesn't provide on Linux.
44+
* SQL Server on Linux - yes, fully supported except sp_DatabaseRestore, which require xp_cmdshell, which Microsoft doesn't provide on Linux.
4645
* Amazon RDS SQL Server - fully supported.
4746
* Azure SQL DB - not supported. Some of the procedures work, but some don't, and Microsoft has a tendency to change DMVs in Azure without warning, so we don't put any effort into supporting it. If it works, great! If not, any changes to make it work would be on you. [See the contributing.md file](CONTRIBUTING.md) for how to do that.
4847

@@ -275,7 +274,6 @@ sp_BlitzIndex focuses on mainstream index types. Other index types have varying
275274

276275
* Fully supported: rowstore indexes, columnstore indexes, temporal tables.
277276
* Columnstore indexes: fully supported. Key columns are shown as includes rather than keys since they're not in a specific order.
278-
* In-Memory OLTP (Hekaton): unsupported. These objects show up in the results, but for more info, you'll want to use sp_BlitzInMemoryOLTP instead.
279277
* Graph tables: unsupported. These objects show up in the results, but we don't do anything special with 'em, like call out that they're graph tables.
280278
* Spatial indexes: unsupported. We call out that they're spatial, but we don't do any special handling for them.
281279
* XML indexes: unsupported. These objects show up in the results, but we don't include the index's columns or sizes.

sp_Blitz.sql

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ AS
155155
,@MinServerMemory bigint
156156
,@MaxServerMemory bigint
157157
,@ColumnStoreIndexesInUse bit
158+
,@QueryStoreInUse bit
158159
,@TraceFileIssue bit
159160
-- Flag for Windows OS to help with Linux support
160161
,@IsWindowsOperatingSystem BIT
@@ -6758,6 +6759,37 @@ IF @ProductVersionMajor >= 10
67586759
AND N''?'' NOT IN (''master'', ''model'', ''msdb'', ''tempdb'', ''DWConfiguration'', ''DWDiagnostics'', ''DWQueue'', ''ReportServer'', ''ReportServerTempDB'') OPTION (RECOMPILE)';
67596760
END;
67606761

6762+
IF NOT EXISTS ( SELECT 1
6763+
FROM #SkipChecks
6764+
WHERE DatabaseName IS NULL AND CheckID = 262 )
6765+
AND EXISTS(SELECT * FROM sys.all_objects WHERE name = 'database_query_store_options')
6766+
AND @ProductVersionMajor > 13 /* The relevant column only exists in 2017+ */
6767+
BEGIN
6768+
6769+
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 262) WITH NOWAIT;
6770+
6771+
EXEC dbo.sp_MSforeachdb 'USE [?];
6772+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
6773+
INSERT INTO #BlitzResults
6774+
(CheckID,
6775+
DatabaseName,
6776+
Priority,
6777+
FindingsGroup,
6778+
Finding,
6779+
URL,
6780+
Details)
6781+
SELECT TOP 1 262,
6782+
N''?'',
6783+
200,
6784+
''Performance'',
6785+
''Query Store Wait Stats Disabled'',
6786+
''https://www.sqlskills.com/blogs/erin/query-store-settings/'',
6787+
(''The new SQL Server 2017 Query Store feature for tracking wait stats has not been enabled on this database. It is very useful for tracking wait stats at a query level.'')
6788+
FROM [?].sys.database_query_store_options
6789+
WHERE desired_state <> 0
6790+
AND wait_stats_capture_mode = 0
6791+
OPTION (RECOMPILE)';
6792+
END;
67616793

67626794
IF @ProductVersionMajor = 13 AND @ProductVersionMinor < 2149 --2016 CU1 has the fix in it
67636795
AND NOT EXISTS ( SELECT 1
@@ -7587,6 +7619,20 @@ IF @ProductVersionMajor >= 10
75877619
IF EXISTS (SELECT * FROM #TemporaryDatabaseResults) SET @ColumnStoreIndexesInUse = 1;
75887620
END;
75897621

7622+
/* Check if Query Store is in use - for Github issue #3527 */
7623+
IF NOT EXISTS ( SELECT 1
7624+
FROM #SkipChecks
7625+
WHERE DatabaseName IS NULL AND CheckID = 74 ) /* Trace flags */
7626+
AND @ProductVersionMajor > 12 /* The relevant column only exists in versions that support Query store */
7627+
BEGIN
7628+
TRUNCATE TABLE #TemporaryDatabaseResults;
7629+
7630+
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 74) WITH NOWAIT;
7631+
7632+
EXEC dbo.sp_MSforeachdb 'USE [?]; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; IF EXISTS(SELECT * FROM sys.databases WHERE is_query_store_on = 1) INSERT INTO #TemporaryDatabaseResults (DatabaseName, Finding) VALUES (DB_NAME(), ''Yup'') OPTION (RECOMPILE);';
7633+
IF EXISTS (SELECT * FROM #TemporaryDatabaseResults) SET @QueryStoreInUse = 1;
7634+
END;
7635+
75907636
/* Non-Default Database Scoped Config - Github issue #598 */
75917637
IF EXISTS ( SELECT * FROM sys.all_objects WHERE [name] = 'database_scoped_configurations' )
75927638
BEGIN
@@ -8354,6 +8400,7 @@ IF @ProductVersionMajor >= 10
83548400
'Informational' AS FindingsGroup ,
83558401
'Trace Flag On' AS Finding ,
83568402
CASE WHEN [T].[TraceFlag] = '834' AND @ColumnStoreIndexesInUse = 1 THEN 'https://support.microsoft.com/en-us/kb/3210239'
8403+
WHEN [T].[TraceFlag] IN ('7745', '7752') THEN 'https://www.sqlskills.com/blogs/erin/query-store-trace-flags/'
83578404
ELSE'https://www.BrentOzar.com/go/traceflags/' END AS URL ,
83588405
'Trace flag ' +
83598406
CASE WHEN [T].[TraceFlag] = '652' THEN '652 enabled globally, which disables pre-fetching during index scans. This is usually a very bad idea.'
@@ -8372,6 +8419,13 @@ IF @ProductVersionMajor >= 10
83728419
WHEN [T].[TraceFlag] = '3226' THEN '3226 enabled globally, which keeps the event log clean by not reporting successful backups.'
83738420
WHEN [T].[TraceFlag] = '3505' THEN '3505 enabled globally, which disables Checkpoints. This is usually a very bad idea.'
83748421
WHEN [T].[TraceFlag] = '4199' THEN '4199 enabled globally, which enables non-default Query Optimizer fixes, changing query plans from the default behaviors.'
8422+
WHEN [T].[TraceFlag] = '7745' AND @ProductVersionMajor > 12 AND @QueryStoreInUse = 1 THEN '7745 enabled globally, which makes shutdowns/failovers quicker by not waiting for Query Store to flush to disk. This good idea loses you the non-flused Query Store data.'
8423+
WHEN [T].[TraceFlag] = '7745' AND @ProductVersionMajor > 12 THEN '7745 enabled globally, which is for Query Store. None of your databases have Query Store enabled, so why do you have this turned on?'
8424+
WHEN [T].[TraceFlag] = '7745' AND @ProductVersionMajor <= 12 THEN '7745 enabled globally, which is for Query Store. Query Store does not exist on your SQL Server version, so why do you have this turned on?'
8425+
WHEN [T].[TraceFlag] = '7752' AND @ProductVersionMajor > 14 THEN '7752 enabled globally, which is for Query Store. However, it has no effect in your SQL Server version. Consider turning it off.'
8426+
WHEN [T].[TraceFlag] = '7752' AND @ProductVersionMajor > 12 AND @QueryStoreInUse = 1 THEN '7752 enabled globally, which stops queries needing to wait on Query Store loading up after database recovery.'
8427+
WHEN [T].[TraceFlag] = '7752' AND @ProductVersionMajor > 12 THEN '7752 enabled globally, which is for Query Store. None of your databases have Query Store enabled, so why do you have this turned on?'
8428+
WHEN [T].[TraceFlag] = '7752' AND @ProductVersionMajor <= 12 THEN '7752 enabled globally, which is for Query Store. Query Store does not exist on your SQL Server version, so why do you have this turned on?'
83758429
WHEN [T].[TraceFlag] = '8048' THEN '8048 enabled globally, which tries to reduce CMEMTHREAD waits on servers with a lot of logical processors.'
83768430
WHEN [T].[TraceFlag] = '8017' AND (CAST(SERVERPROPERTY('Edition') AS NVARCHAR(1000)) LIKE N'%Express%') THEN '8017 is enabled globally, but this is the default for Express Edition.'
83778431
WHEN [T].[TraceFlag] = '8017' AND (CAST(SERVERPROPERTY('Edition') AS NVARCHAR(1000)) NOT LIKE N'%Express%') THEN '8017 is enabled globally, which disables the creation of schedulers for all logical processors.'

sp_BlitzLock.sql

Lines changed: 58 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ ALTER PROCEDURE
1818
@EventSessionName sysname = N'system_health',
1919
@TargetSessionType sysname = NULL,
2020
@VictimsOnly bit = 0,
21-
@Debug bit = 0,
21+
@DeadlockType nvarchar(20) = NULL,
22+
@Debug bit = 0,
2223
@Help bit = 0,
2324
@Version varchar(30) = NULL OUTPUT,
2425
@VersionDate datetime = NULL OUTPUT,
@@ -198,7 +199,7 @@ BEGIN
198199
@StartDateOriginal datetime = @StartDate,
199200
@EndDateOriginal datetime = @EndDate,
200201
@StartDateUTC datetime,
201-
@EndDateUTC datetime;
202+
@EndDateUTC datetime;;
202203

203204
/*Temporary objects used in the procedure*/
204205
DECLARE
@@ -708,50 +709,63 @@ BEGIN
708709
END CATCH;
709710
END;
710711

712+
IF @DeadlockType IS NOT NULL
713+
BEGIN
714+
SELECT
715+
@DeadlockType =
716+
CASE
717+
WHEN LOWER(@DeadlockType) LIKE 'regular%'
718+
THEN N'Regular Deadlock'
719+
WHEN LOWER(@DeadlockType) LIKE N'parallel%'
720+
THEN N'Parallel Deadlock'
721+
ELSE NULL
722+
END;
723+
END;
724+
711725
/*If @TargetSessionType, we need to figure out if it's ring buffer or event file*/
712726
/*Azure has differently named views, so we need to separate. Thanks, Azure.*/
713727

714-
IF
715-
(
716-
@Azure = 0
717-
AND @TargetSessionType IS NULL
718-
)
719-
BEGIN
720-
RAISERROR('@TargetSessionType is NULL, assigning for non-Azure instance', 0, 1) WITH NOWAIT;
721-
722-
SELECT TOP (1)
723-
@TargetSessionType = t.target_name
724-
FROM sys.dm_xe_sessions AS s
725-
JOIN sys.dm_xe_session_targets AS t
726-
ON s.address = t.event_session_address
727-
WHERE s.name = @EventSessionName
728-
AND t.target_name IN (N'event_file', N'ring_buffer')
729-
ORDER BY t.target_name
730-
OPTION(RECOMPILE);
731-
732-
RAISERROR('@TargetSessionType assigned as %s for non-Azure', 0, 1, @TargetSessionType) WITH NOWAIT;
733-
END;
728+
IF
729+
(
730+
@Azure = 0
731+
AND @TargetSessionType IS NULL
732+
)
733+
BEGIN
734+
RAISERROR('@TargetSessionType is NULL, assigning for non-Azure instance', 0, 1) WITH NOWAIT;
735+
736+
SELECT TOP (1)
737+
@TargetSessionType = t.target_name
738+
FROM sys.dm_xe_sessions AS s
739+
JOIN sys.dm_xe_session_targets AS t
740+
ON s.address = t.event_session_address
741+
WHERE s.name = @EventSessionName
742+
AND t.target_name IN (N'event_file', N'ring_buffer')
743+
ORDER BY t.target_name
744+
OPTION(RECOMPILE);
734745

735-
IF
736-
(
737-
@Azure = 1
738-
AND @TargetSessionType IS NULL
739-
)
740-
BEGIN
741-
RAISERROR('@TargetSessionType is NULL, assigning for Azure instance', 0, 1) WITH NOWAIT;
746+
RAISERROR('@TargetSessionType assigned as %s for non-Azure', 0, 1, @TargetSessionType) WITH NOWAIT;
747+
END;
742748

743-
SELECT TOP (1)
744-
@TargetSessionType = t.target_name
745-
FROM sys.dm_xe_database_sessions AS s
746-
JOIN sys.dm_xe_database_session_targets AS t
747-
ON s.address = t.event_session_address
748-
WHERE s.name = @EventSessionName
749-
AND t.target_name IN (N'event_file', N'ring_buffer')
750-
ORDER BY t.target_name
751-
OPTION(RECOMPILE);
749+
IF
750+
(
751+
@Azure = 1
752+
AND @TargetSessionType IS NULL
753+
)
754+
BEGIN
755+
RAISERROR('@TargetSessionType is NULL, assigning for Azure instance', 0, 1) WITH NOWAIT;
756+
757+
SELECT TOP (1)
758+
@TargetSessionType = t.target_name
759+
FROM sys.dm_xe_database_sessions AS s
760+
JOIN sys.dm_xe_database_session_targets AS t
761+
ON s.address = t.event_session_address
762+
WHERE s.name = @EventSessionName
763+
AND t.target_name IN (N'event_file', N'ring_buffer')
764+
ORDER BY t.target_name
765+
OPTION(RECOMPILE);
752766

753-
RAISERROR('@TargetSessionType assigned as %s for Azure', 0, 1, @TargetSessionType) WITH NOWAIT;
754-
END;
767+
RAISERROR('@TargetSessionType assigned as %s for Azure', 0, 1, @TargetSessionType) WITH NOWAIT;
768+
END;
755769

756770

757771
/*The system health stuff gets handled different from user extended events.*/
@@ -3449,7 +3463,8 @@ BEGIN
34493463
AND (d.client_app = @AppName OR @AppName IS NULL)
34503464
AND (d.host_name = @HostName OR @HostName IS NULL)
34513465
AND (d.login_name = @LoginName OR @LoginName IS NULL)
3452-
OPTION (RECOMPILE, LOOP JOIN, HASH JOIN);
3466+
AND (d.deadlock_type = @DeadlockType OR @DeadlockType IS NULL)
3467+
OPTION (RECOMPILE, LOOP JOIN, HASH JOIN);
34533468

34543469
UPDATE d
34553470
SET d.inputbuf =
@@ -4063,6 +4078,8 @@ BEGIN
40634078
@TargetSessionType,
40644079
VictimsOnly =
40654080
@VictimsOnly,
4081+
DeadlockType =
4082+
@DeadlockType,
40664083
Debug =
40674084
@Debug,
40684085
Help =

0 commit comments

Comments
 (0)