Skip to content

Commit 3b7996a

Browse files
Merge pull request #580 from ReeceGoding/dev
sp_QuickieStore: Made skipping maintenance plans optional
2 parents 7ecff0d + 0ee921a commit 3b7996a

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

sp_QuickieStore/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 11 additions & 1 deletion
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'
@@ -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)