Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sp_QuickieStore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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/)
* [Blog post](https://www.erikdarling.com/sp_quickiestore/)
12 changes: 11 additions & 1 deletion sp_QuickieStore/sp_QuickieStore.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -10208,6 +10216,8 @@ BEGIN
@regression_direction,
include_query_hash_totals =
@include_query_hash_totals,
include_maintenance =
@include_maintenance,
help =
@help,
debug =
Expand Down