Skip to content

Commit 37adfdd

Browse files
Merge pull request #589 from erikdarlingdata/dev
Dev
2 parents 4ad282c + 9c2e45f commit 37adfdd

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

sp_PerfCheck/sp_PerfCheck.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
387387
name sysname NOT NULL,
388388
database_id integer NOT NULL,
389389
compatibility_level tinyint NOT NULL,
390-
collation_name sysname NOT NULL,
390+
collation_name sysname NULL,
391391
user_access_desc nvarchar(60) NOT NULL,
392392
is_read_only bit NOT NULL,
393393
is_auto_close_on bit NOT NULL,
@@ -411,8 +411,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
411411
is_query_store_on bit NOT NULL,
412412
is_distributor bit NOT NULL,
413413
is_cdc_enabled bit NOT NULL,
414-
target_recovery_time_in_seconds integer NOT NULL,
415-
delayed_durability_desc nvarchar(60) NOT NULL,
414+
target_recovery_time_in_seconds integer NULL,
415+
delayed_durability_desc nvarchar(60) NULL,
416416
is_accelerated_database_recovery_on bit NOT NULL,
417417
is_ledger_on bit NULL
418418
);
@@ -571,7 +571,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
571571
avg_wait_ms AS (wait_time_ms / NULLIF(waiting_tasks_count, 0)),
572572
percentage decimal(5, 2) NOT NULL,
573573
signal_wait_time_ms bigint NOT NULL,
574-
wait_time_percent_of_uptime decimal(5, 2) NULL,
574+
wait_time_percent_of_uptime decimal(6, 2) NULL,
575575
category nvarchar(50) NOT NULL
576576
);
577577

@@ -2381,7 +2381,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23812381
THEN 0
23822382
ELSE CONVERT(decimal(18, 2), SUM(fs.io_stall_write_ms) * 1.0 / SUM(fs.num_of_writes))
23832383
END,
2384-
total_size_mb = CONVERT(decimal(18, 2), SUM(mf.size) * 8.0 / 1024.0)
2384+
total_size_mb = CONVERT(decimal(18, 2), SUM(CONVERT(bigint, mf.size)) * 8.0 / 1024.0)
23852385
FROM sys.dm_io_virtual_file_stats
23862386
(' +
23872387
CASE
@@ -2581,9 +2581,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25812581
CONVERT(nvarchar(10), CONVERT(decimal(10, 2), io.avg_write_stall_ms)) +
25822582
N' ms. ' +
25832583
N'Total read: ' +
2584-
CONVERT(nvarchar(20), CONVERT(decimal(10, 2), io.read_io_mb)) +
2584+
CONVERT(nvarchar(20), CONVERT(decimal(18, 2), io.read_io_mb)) +
25852585
N' MB, Total write: ' +
2586-
CONVERT(nvarchar(20), CONVERT(decimal(10, 2), io.write_io_mb)) +
2586+
CONVERT(nvarchar(20), CONVERT(decimal(18, 2), io.write_io_mb)) +
25872587
N' MB. ' +
25882588
N'This indicates slow I/O subsystem performance for this database.',
25892589
url = N'https://erikdarling.com/sp_PerfCheck#IOStalls'

sp_PressureDetector/sp_PressureDetector.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ OPTION(MAXDOP 1, RECOMPILE);',
870870
writes bigint NULL,
871871
logical_reads bigint NULL,
872872
granted_query_memory_gb decimal(38,2) NULL,
873-
transaction_isolation_level nvarchar(30) NULL,
873+
transaction_isolation_level sysname NULL,
874874
dop integer NULL,
875875
parallel_worker_count integer NULL,
876876
plan_handle varbinary(64) NULL,

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)