Skip to content

Commit 03b0120

Browse files
authored
Merge pull request #3531 from ReeceGoding/patch-15
sp_Blitz: Add more detail to Query Store Trace Flag rows
2 parents 9feae98 + 87a59a0 commit 03b0120

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

sp_Blitz.sql

Lines changed: 23 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
@@ -7587,6 +7588,20 @@ IF @ProductVersionMajor >= 10
75877588
IF EXISTS (SELECT * FROM #TemporaryDatabaseResults) SET @ColumnStoreIndexesInUse = 1;
75887589
END;
75897590

7591+
/* Check if Query Store is in use - for Github issue #3527 */
7592+
IF NOT EXISTS ( SELECT 1
7593+
FROM #SkipChecks
7594+
WHERE DatabaseName IS NULL AND CheckID = 74 ) /* Trace flags */
7595+
AND @ProductVersionMajor > 12 /* The relevant column only exists in versions that support Query store */
7596+
BEGIN
7597+
TRUNCATE TABLE #TemporaryDatabaseResults;
7598+
7599+
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 74) WITH NOWAIT;
7600+
7601+
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);';
7602+
IF EXISTS (SELECT * FROM #TemporaryDatabaseResults) SET @QueryStoreInUse = 1;
7603+
END;
7604+
75907605
/* Non-Default Database Scoped Config - Github issue #598 */
75917606
IF EXISTS ( SELECT * FROM sys.all_objects WHERE [name] = 'database_scoped_configurations' )
75927607
BEGIN
@@ -8354,6 +8369,7 @@ IF @ProductVersionMajor >= 10
83548369
'Informational' AS FindingsGroup ,
83558370
'Trace Flag On' AS Finding ,
83568371
CASE WHEN [T].[TraceFlag] = '834' AND @ColumnStoreIndexesInUse = 1 THEN 'https://support.microsoft.com/en-us/kb/3210239'
8372+
WHEN [T].[TraceFlag] IN ('7745', '7752') THEN 'https://www.sqlskills.com/blogs/erin/query-store-trace-flags/'
83578373
ELSE'https://www.BrentOzar.com/go/traceflags/' END AS URL ,
83588374
'Trace flag ' +
83598375
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 +8388,13 @@ IF @ProductVersionMajor >= 10
83728388
WHEN [T].[TraceFlag] = '3226' THEN '3226 enabled globally, which keeps the event log clean by not reporting successful backups.'
83738389
WHEN [T].[TraceFlag] = '3505' THEN '3505 enabled globally, which disables Checkpoints. This is usually a very bad idea.'
83748390
WHEN [T].[TraceFlag] = '4199' THEN '4199 enabled globally, which enables non-default Query Optimizer fixes, changing query plans from the default behaviors.'
8391+
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.'
8392+
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?'
8393+
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?'
8394+
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.'
8395+
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.'
8396+
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?'
8397+
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?'
83758398
WHEN [T].[TraceFlag] = '8048' THEN '8048 enabled globally, which tries to reduce CMEMTHREAD waits on servers with a lot of logical processors.'
83768399
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.'
83778400
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.'

0 commit comments

Comments
 (0)