Skip to content

Commit f5ac525

Browse files
2 parents a5a7c77 + 3b7996a commit f5ac525

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

sp_QuickieStore/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Use the `@expert_mode` parameter to return additional details.
5151
| @query_text_search | nvarchar | query text to search for | a string; leading and trailing wildcards will be added if missing | NULL |
5252
| @query_text_search_not | nvarchar | query text to exclude | a string; leading and trailing wildcards will be added if missing | NULL |
5353
| @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 |
54-
| @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 (\) | \ |
54+
| @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 (\\) | \ |
5555
| @only_queries_with_hints | bit | only return queries with query hints | 0 or 1 | 0 |
5656
| @only_queries_with_feedback | bit | only return queries with query feedback | 0 or 1 | 0 |
5757
| @only_queries_with_variants | bit | only return queries with query variants | 0 or 1 | 0 |
@@ -73,6 +73,7 @@ Use the `@expert_mode` parameter to return additional details.
7373
| @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 |
7474
| @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 |
7575
| @include_query_hash_totals | bit | will add an additional column to final output with total resource usage by query hash | 0 or 1 | 0 |
76+
| @include_maintenance | bit | Set this bit to 1 to add maintenance operations such as index creation to the result set | 0 or 1 | 0 |
7677
| @help | bit | how you got here | 0 or 1 | 0 |
7778
| @debug | bit | prints dynamic sql, statement length, parameter and variable values, and raw temp table contents | 0 or 1 | 0 |
7879
| @troubleshoot_performance | bit | set statistics xml on for queries against views | 0 or 1 | 0 |
@@ -129,4 +130,4 @@ EXECUTE dbo.sp_QuickieStore
129130

130131
## Resources
131132
* [YouTube playlist](https://www.youtube.com/playlist?list=PLt4QZ-7lfQie1XZHEm0HN-Zt1S7LFEx1P)
132-
* [Blog post](https://www.erikdarling.com/sp_quickiestore/)
133+
* [Blog post](https://www.erikdarling.com/sp_quickiestore/)

sp_QuickieStore/sp_QuickieStore.sql

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ ALTER PROCEDURE
100100
@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.*/
101101
@regression_direction varchar(20) = NULL, /*when comparing against the regression baseline, want do you want the results sorted by ('magnitude', 'improved', or 'regressed')?*/
102102
@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*/
103+
@include_maintenance bit = 0, /*Set this bit to 1 to add maintenance operations such as index creation to the result set*/
103104
@help bit = 0, /*return available parameter details, etc.*/
104105
@debug bit = 0, /*prints dynamic sql, statement length, parameter and variable values, and raw temp table contents*/
105106
@troubleshoot_performance bit = 0, /*set statistics xml on for queries against views*/
@@ -215,6 +216,7 @@ BEGIN
215216
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.'
216217
WHEN N'@regression_direction' THEN 'when comparing against any regression baseline, what do you want the results sorted by (''magnitude'', ''improved'', or ''regressed'')?'
217218
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'
219+
WHEN N'@include_maintenance' THEN N'Set this bit to 1 to add maintenance operations such as index creation to the result set'
218220
WHEN N'@help' THEN 'how you got here'
219221
WHEN N'@debug' THEN 'prints dynamic sql, statement length, parameter and variable values, and raw temp table contents'
220222
WHEN N'@troubleshoot_performance' THEN 'set statistics xml on for queries against views'
@@ -270,6 +272,7 @@ BEGIN
270272
WHEN N'@regression_comparator' THEN 'relative, absolute'
271273
WHEN N'@regression_direction' THEN 'regressed, worse, improved, better, magnitude, absolute, whatever'
272274
WHEN N'@include_query_hash_totals' THEN N'0 or 1'
275+
WHEN N'@include_maintenance' THEN N'0 or 1'
273276
WHEN N'@help' THEN '0 or 1'
274277
WHEN N'@debug' THEN '0 or 1'
275278
WHEN N'@troubleshoot_performance' THEN '0 or 1'
@@ -325,6 +328,7 @@ BEGIN
325328
WHEN N'@regression_comparator' THEN 'NULL; absolute if @regression_baseline_start_date is specified'
326329
WHEN N'@regression_direction' THEN 'NULL; regressed if @regression_baseline_start_date is specified'
327330
WHEN N'@include_query_hash_totals' THEN N'0'
331+
WHEN N'@include_maintenance' THEN N'0'
328332
WHEN N'@help' THEN '0'
329333
WHEN N'@debug' THEN '0'
330334
WHEN N'@troubleshoot_performance' THEN '0'
@@ -782,7 +786,7 @@ Hold plan_ids for matching wait filter
782786
CREATE TABLE
783787
#wait_filter
784788
(
785-
plan_id bigint PRIMARY KEY
789+
plan_id bigint PRIMARY KEY CLUSTERED
786790
);
787791

788792
/*
@@ -1276,19 +1280,19 @@ CREATE TABLE
12761280
CREATE TABLE
12771281
#include_databases
12781282
(
1279-
database_name sysname PRIMARY KEY
1283+
database_name sysname PRIMARY KEY CLUSTERED
12801284
);
12811285

12821286
CREATE TABLE
12831287
#exclude_databases
12841288
(
1285-
database_name sysname PRIMARY KEY
1289+
database_name sysname PRIMARY KEY CLUSTERED
12861290
);
12871291

12881292
CREATE TABLE
12891293
#requested_but_skipped_databases
12901294
(
1291-
database_name sysname PRIMARY KEY,
1295+
database_name sysname PRIMARY KEY CLUSTERED,
12921296
reason varchar(100) NOT NULL
12931297
);
12941298

@@ -2716,6 +2720,8 @@ SELECT
27162720
ISNULL(@workdays, 0),
27172721
@include_query_hash_totals =
27182722
ISNULL(@include_query_hash_totals, 0),
2723+
@include_maintenance =
2724+
ISNULL(@include_maintenance, 0),
27192725
/*
27202726
doing start and end date last because they're more complicated
27212727
if start or end date is null,
@@ -5145,7 +5151,8 @@ END;
51455151
/*
51465152
This section screens out index create and alter statements because who cares
51475153
*/
5148-
5154+
IF @include_maintenance = 0
5155+
BEGIN
51495156
SELECT
51505157
@current_table = 'inserting #maintenance_plans',
51515158
@sql = @isolation_level;
@@ -5225,6 +5232,7 @@ SELECT
52255232
FROM #maintenance_plans AS mp
52265233
WHERE mp.plan_id = qsrs.plan_id
52275234
)' + @nc10;
5235+
END;
52285236

52295237
/*
52305238
Tidy up the where clause a bit
@@ -10208,6 +10216,8 @@ BEGIN
1020810216
@regression_direction,
1020910217
include_query_hash_totals =
1021010218
@include_query_hash_totals,
10219+
include_maintenance =
10220+
@include_maintenance,
1021110221
help =
1021210222
@help,
1021310223
debug =

0 commit comments

Comments
 (0)