From 8411e586789e2e0b4f25851f16d371d41f5f4d0c Mon Sep 17 00:00:00 2001 From: Vlad Drumea <48413726+VladDBA@users.noreply.github.com> Date: Sat, 19 Apr 2025 17:24:43 +0300 Subject: [PATCH 1/6] Markdown needs the escape character escaped --- sp_QuickieStore/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sp_QuickieStore/README.md b/sp_QuickieStore/README.md index c7b73023..6c29f1f9 100644 --- a/sp_QuickieStore/README.md +++ b/sp_QuickieStore/README.md @@ -51,7 +51,7 @@ Use the `@expert_mode` parameter to return additional details. | @query_text_search | nvarchar | query text to search for | a string; leading and trailing wildcards will be added if missing | NULL | | @query_text_search_not | nvarchar | query text to exclude | a string; leading and trailing wildcards will be added if missing | NULL | | @escape_brackets | bit | Set this bit to 1 to search for query text containing square brackets (common in .NET Entity Framework and other ORM queries) | 0 or 1 | 0 | -| @escape_character | nchar | Sets the ESCAPE character for special character searches, defaults to the SQL standard backslash (\) character | some escape character, SQL standard is backslash (\) | \ | +| @escape_character | nchar | Sets the ESCAPE character for special character searches, defaults to the SQL standard backslash (\\) character | some escape character, SQL standard is backslash (\\) | \ | | @only_queries_with_hints | bit | only return queries with query hints | 0 or 1 | 0 | | @only_queries_with_feedback | bit | only return queries with query feedback | 0 or 1 | 0 | | @only_queries_with_variants | bit | only return queries with query variants | 0 or 1 | 0 | From 8de71a3355ebce201ddfe7ef0be5c762aa2ef986 Mon Sep 17 00:00:00 2001 From: RG Date: Mon, 21 Apr 2025 20:38:55 +0100 Subject: [PATCH 2/6] Consistent PRIMARY KEY syntax. --- sp_QuickieStore/sp_QuickieStore.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sp_QuickieStore/sp_QuickieStore.sql b/sp_QuickieStore/sp_QuickieStore.sql index 75252b4c..873cf6c9 100644 --- a/sp_QuickieStore/sp_QuickieStore.sql +++ b/sp_QuickieStore/sp_QuickieStore.sql @@ -782,7 +782,7 @@ Hold plan_ids for matching wait filter CREATE TABLE #wait_filter ( - plan_id bigint PRIMARY KEY + plan_id bigint PRIMARY KEY CLUSTERED ); /* @@ -1276,19 +1276,19 @@ CREATE TABLE CREATE TABLE #include_databases ( - database_name sysname PRIMARY KEY + database_name sysname PRIMARY KEY CLUSTERED ); CREATE TABLE #exclude_databases ( - database_name sysname PRIMARY KEY + database_name sysname PRIMARY KEY CLUSTERED ); CREATE TABLE #requested_but_skipped_databases ( - database_name sysname PRIMARY KEY, + database_name sysname PRIMARY KEY CLUSTERED, reason varchar(100) NOT NULL ); From 0ee921ad39e3af8cc94f2c46f4e2f125b6dfe625 Mon Sep 17 00:00:00 2001 From: RG Date: Tue, 22 Apr 2025 21:15:09 +0100 Subject: [PATCH 3/6] Made skipping maintenance plans optional, closes #577. Nothing really intelligent done here. Boilerplate aside, I just wrapped the bit that does the skipping in an IF. --- sp_QuickieStore/README.md | 3 ++- sp_QuickieStore/sp_QuickieStore.sql | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sp_QuickieStore/README.md b/sp_QuickieStore/README.md index 6c29f1f9..59ccd568 100644 --- a/sp_QuickieStore/README.md +++ b/sp_QuickieStore/README.md @@ -73,6 +73,7 @@ Use the `@expert_mode` parameter to return additional details. | @regression_comparator | varchar | what difference to use ('relative' or 'absolute') when comparing @sort_order's metric for the normal time period with any regression time period. | relative, absolute | NULL; absolute if @regression_baseline_start_date is specified | | @regression_direction | varchar | when comparing against any regression baseline, what do you want the results sorted by ('magnitude', 'improved', or 'regressed')? | regressed, worse, improved, better, magnitude, absolute, whatever | NULL; regressed if @regression_baseline_start_date is specified | | @include_query_hash_totals | bit | will add an additional column to final output with total resource usage by query hash | 0 or 1 | 0 | +| @include_maintenance | bit | Set this bit to 1 to add maintenance operations such as index creation to the result set | 0 or 1 | 0 | | @help | bit | how you got here | 0 or 1 | 0 | | @debug | bit | prints dynamic sql, statement length, parameter and variable values, and raw temp table contents | 0 or 1 | 0 | | @troubleshoot_performance | bit | set statistics xml on for queries against views | 0 or 1 | 0 | @@ -129,4 +130,4 @@ EXECUTE dbo.sp_QuickieStore ## Resources * [YouTube playlist](https://www.youtube.com/playlist?list=PLt4QZ-7lfQie1XZHEm0HN-Zt1S7LFEx1P) -* [Blog post](https://www.erikdarling.com/sp_quickiestore/) \ No newline at end of file +* [Blog post](https://www.erikdarling.com/sp_quickiestore/) diff --git a/sp_QuickieStore/sp_QuickieStore.sql b/sp_QuickieStore/sp_QuickieStore.sql index 873cf6c9..4a452361 100644 --- a/sp_QuickieStore/sp_QuickieStore.sql +++ b/sp_QuickieStore/sp_QuickieStore.sql @@ -100,6 +100,7 @@ ALTER PROCEDURE @regression_comparator varchar(20) = NULL, /*what difference to use ('relative' or 'absolute') when comparing @sort_order's metric for the normal time period with the regression time period.*/ @regression_direction varchar(20) = NULL, /*when comparing against the regression baseline, want do you want the results sorted by ('magnitude', 'improved', or 'regressed')?*/ @include_query_hash_totals bit = 0, /*will add an additional column to final output with total resource usage by query hash, may be skewed by query_hash and query_plan_hash bugs with forced plans/plan guides*/ + @include_maintenance bit = 0, /*Set this bit to 1 to add maintenance operations such as index creation to the result set*/ @help bit = 0, /*return available parameter details, etc.*/ @debug bit = 0, /*prints dynamic sql, statement length, parameter and variable values, and raw temp table contents*/ @troubleshoot_performance bit = 0, /*set statistics xml on for queries against views*/ @@ -215,6 +216,7 @@ BEGIN WHEN N'@regression_comparator' THEN 'what difference to use (''relative'' or ''absolute'') when comparing @sort_order''s metric for the normal time period with any regression time period.' WHEN N'@regression_direction' THEN 'when comparing against any regression baseline, what do you want the results sorted by (''magnitude'', ''improved'', or ''regressed'')?' WHEN N'@include_query_hash_totals' THEN N'will add an additional column to final output with total resource usage by query hash, may be skewed by query_hash and query_plan_hash bugs with forced plans/plan guides' + WHEN N'@include_maintenance' THEN N'Set this bit to 1 to add maintenance operations such as index creation to the result set' WHEN N'@help' THEN 'how you got here' WHEN N'@debug' THEN 'prints dynamic sql, statement length, parameter and variable values, and raw temp table contents' WHEN N'@troubleshoot_performance' THEN 'set statistics xml on for queries against views' @@ -270,6 +272,7 @@ BEGIN WHEN N'@regression_comparator' THEN 'relative, absolute' WHEN N'@regression_direction' THEN 'regressed, worse, improved, better, magnitude, absolute, whatever' WHEN N'@include_query_hash_totals' THEN N'0 or 1' + WHEN N'@include_maintenance' THEN N'0 or 1' WHEN N'@help' THEN '0 or 1' WHEN N'@debug' THEN '0 or 1' WHEN N'@troubleshoot_performance' THEN '0 or 1' @@ -325,6 +328,7 @@ BEGIN WHEN N'@regression_comparator' THEN 'NULL; absolute if @regression_baseline_start_date is specified' WHEN N'@regression_direction' THEN 'NULL; regressed if @regression_baseline_start_date is specified' WHEN N'@include_query_hash_totals' THEN N'0' + WHEN N'@include_maintenance' THEN N'0' WHEN N'@help' THEN '0' WHEN N'@debug' THEN '0' WHEN N'@troubleshoot_performance' THEN '0' @@ -2716,6 +2720,8 @@ SELECT ISNULL(@workdays, 0), @include_query_hash_totals = ISNULL(@include_query_hash_totals, 0), + @include_maintenance = + ISNULL(@include_maintenance, 0), /* doing start and end date last because they're more complicated if start or end date is null, @@ -5145,7 +5151,8 @@ END; /* This section screens out index create and alter statements because who cares */ - +IF @include_maintenance = 0 +BEGIN SELECT @current_table = 'inserting #maintenance_plans', @sql = @isolation_level; @@ -5225,6 +5232,7 @@ SELECT FROM #maintenance_plans AS mp WHERE mp.plan_id = qsrs.plan_id )' + @nc10; +END; /* Tidy up the where clause a bit @@ -10208,6 +10216,8 @@ BEGIN @regression_direction, include_query_hash_totals = @include_query_hash_totals, + include_maintenance = + @include_maintenance, help = @help, debug = From a5a7c771aa145a2ed81ca567b35f96f6f4181b64 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Wed, 23 Apr 2025 08:59:54 -0400 Subject: [PATCH 4/6] Update sp_PerfCheck.sql --- sp_PerfCheck/sp_PerfCheck.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sp_PerfCheck/sp_PerfCheck.sql b/sp_PerfCheck/sp_PerfCheck.sql index 1195b339..d2642107 100644 --- a/sp_PerfCheck/sp_PerfCheck.sql +++ b/sp_PerfCheck/sp_PerfCheck.sql @@ -2381,7 +2381,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THEN 0 ELSE CONVERT(decimal(18, 2), SUM(fs.io_stall_write_ms) * 1.0 / SUM(fs.num_of_writes)) END, - total_size_mb = CONVERT(decimal(18, 2), SUM(mf.size) * 8.0 / 1024.0) + total_size_mb = CONVERT(decimal(18, 2), SUM(CONVERT(bigint, mf.size)) * 8.0 / 1024.0) FROM sys.dm_io_virtual_file_stats (' + CASE From c223c2f967c20c7a64c55a1588b217b5e21ee71b Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Thu, 24 Apr 2025 08:31:27 -0400 Subject: [PATCH 5/6] Closes #582 Closes #582 --- sp_PerfCheck/sp_PerfCheck.sql | 2 +- sp_PressureDetector/sp_PressureDetector.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sp_PerfCheck/sp_PerfCheck.sql b/sp_PerfCheck/sp_PerfCheck.sql index d2642107..835c9db5 100644 --- a/sp_PerfCheck/sp_PerfCheck.sql +++ b/sp_PerfCheck/sp_PerfCheck.sql @@ -387,7 +387,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. name sysname NOT NULL, database_id integer NOT NULL, compatibility_level tinyint NOT NULL, - collation_name sysname NOT NULL, + collation_name sysname NULL, user_access_desc nvarchar(60) NOT NULL, is_read_only bit NOT NULL, is_auto_close_on bit NOT NULL, diff --git a/sp_PressureDetector/sp_PressureDetector.sql b/sp_PressureDetector/sp_PressureDetector.sql index fc6bcaf4..5a6899b2 100644 --- a/sp_PressureDetector/sp_PressureDetector.sql +++ b/sp_PressureDetector/sp_PressureDetector.sql @@ -870,7 +870,7 @@ OPTION(MAXDOP 1, RECOMPILE);', writes bigint NULL, logical_reads bigint NULL, granted_query_memory_gb decimal(38,2) NULL, - transaction_isolation_level nvarchar(30) NULL, + transaction_isolation_level sysname NULL, dop integer NULL, parallel_worker_count integer NULL, plan_handle varbinary(64) NULL, From 9639d0735db1c54d4f9a02d29e9a76d88824c296 Mon Sep 17 00:00:00 2001 From: krustydb Date: Thu, 24 Apr 2025 15:49:40 +0200 Subject: [PATCH 6/6] #583 sp_PerfCheck Overflow Errors Msg 8115, Level 16, State 8, Procedure dbo.sp_PerfCheck, Line 2100 (Batch Start Line 2) Arithmethic overflow error converting numeric to data type numeric --- sp_PerfCheck/sp_PerfCheck.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sp_PerfCheck/sp_PerfCheck.sql b/sp_PerfCheck/sp_PerfCheck.sql index 835c9db5..40643546 100644 --- a/sp_PerfCheck/sp_PerfCheck.sql +++ b/sp_PerfCheck/sp_PerfCheck.sql @@ -2581,9 +2581,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CONVERT(nvarchar(10), CONVERT(decimal(10, 2), io.avg_write_stall_ms)) + N' ms. ' + N'Total read: ' + - CONVERT(nvarchar(20), CONVERT(decimal(10, 2), io.read_io_mb)) + + CONVERT(nvarchar(20), CONVERT(decimal(18, 2), io.read_io_mb)) + N' MB, Total write: ' + - CONVERT(nvarchar(20), CONVERT(decimal(10, 2), io.write_io_mb)) + + CONVERT(nvarchar(20), CONVERT(decimal(18, 2), io.write_io_mb)) + N' MB. ' + N'This indicates slow I/O subsystem performance for this database.', url = N'https://erikdarling.com/sp_PerfCheck#IOStalls'