Skip to content

Commit

Permalink
Added check for 'Query Store Unusually Configured'
Browse files Browse the repository at this point in the history
  • Loading branch information
ReeceGoding authored Jul 3, 2024
1 parent 1af3788 commit 29f11bc
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions sp_Blitz.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6861,6 +6861,41 @@ IF @ProductVersionMajor >= 10
AND desired_state <> actual_state
OPTION (RECOMPILE)';
END;

IF NOT EXISTS ( SELECT 1
FROM #SkipChecks
WHERE DatabaseName IS NULL AND CheckID = 265 )
AND EXISTS(SELECT * FROM sys.all_objects WHERE name = 'database_query_store_options')
BEGIN
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 265) WITH NOWAIT;

EXEC dbo.sp_MSforeachdb 'USE [?];
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
INSERT INTO #BlitzResults
(CheckID,
DatabaseName,
Priority,
FindingsGroup,
Finding,
URL,
Details)
SELECT TOP 1 265,
N''?'',
200,
''Performance'',
''Query Store Unusually Configured'',
''https://www.sqlskills.com/blogs/erin/query-store-best-practices/'',
(''The '' + query_capture_mode_desc + '' query capture mode '' +
CASE query_capture_mode_desc
WHEN ''ALL'' THEN ''captures more data than you will probably use. If your workload is heavily ad-hoc, then it can also cause Query Store to capture so much that it turns itself off.''
WHEN ''NONE'' THEN ''stops Query Store capturing data for new queries.''
WHEN ''CUSTOM'' THEN ''suggests that somebody has gone out of their way to only capture exactly what they want.''
ELSE ''is not documented.'' END)
FROM [?].sys.database_query_store_options
WHERE desired_state <> 0 /* No point in checking this if Query Store is off. */
AND query_capture_mode_desc <> ''AUTO''
OPTION (RECOMPILE)';
END;

IF @ProductVersionMajor = 13 AND @ProductVersionMinor < 2149 --2016 CU1 has the fix in it
AND NOT EXISTS ( SELECT 1
Expand Down

0 comments on commit 29f11bc

Please sign in to comment.