Skip to content

Commit e5e1ec6

Browse files
committed
#3620 paused index operation
Added warnings in sp_BlitzIndex and sp_Blitz. Closes #3620.
1 parent adad5ff commit e5e1ec6

File tree

3 files changed

+82
-69
lines changed

3 files changed

+82
-69
lines changed

Documentation/sp_Blitz_Checks_by_Priority.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Before adding a new check, make sure to add a Github issue for it first, and hav
66

77
If you want to change anything about a check - the priority, finding, URL, or ID - open a Github issue first. The relevant scripts have to be updated too.
88

9-
CURRENT HIGH CHECKID: 266.
10-
If you want to add a new one, start at 267.
9+
CURRENT HIGH CHECKID: 267.
10+
If you want to add a new one, start at 268.
1111

1212
| Priority | FindingsGroup | Finding | URL | CheckID |
1313
|----------|-----------------------------|---------------------------------------------------------|------------------------------------------------------------------------|----------|
@@ -276,6 +276,7 @@ If you want to add a new one, start at 267.
276276
| 210 | Non-Default Database Scoped Config | Legacy CE | https://www.BrentOzar.com/go/dbscope | 195 |
277277
| 210 | Non-Default Database Scoped Config | Parameter Sniffing | https://www.BrentOzar.com/go/dbscope | 196 |
278278
| 210 | Non-Default Database Scoped Config | Query Optimizer Hotfixes | https://www.BrentOzar.com/go/dbscope | 197 |
279+
| 210 | Non-Default Database Scoped Config | All Others | https://www.BrentOzar.com/go/dbscope | 267 |
279280
| 230 | Security | Control Server Permissions | https://www.BrentOzar.com/go/sa | 104 |
280281
| 230 | Security | Database Owner <> SA | https://www.BrentOzar.com/go/owndb | 55 |
281282
| 230 | Security | Database Owner is Unknown | | 213 |

sp_Blitz.sql

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7749,52 +7749,44 @@ IF @ProductVersionMajor >= 10
77497749
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d] through [%d] and [%d] through [%d].', 0, 1, 194, 197, 237, 255) WITH NOWAIT;
77507750

77517751
INSERT INTO #DatabaseScopedConfigurationDefaults (configuration_id, [name], default_value, default_value_for_secondary, CheckID)
7752-
SELECT 1, 'MAXDOP', '0', NULL, 194
7753-
UNION ALL
7754-
SELECT 2, 'LEGACY_CARDINALITY_ESTIMATION', '0', NULL, 195
7755-
UNION ALL
7756-
SELECT 3, 'PARAMETER_SNIFFING', '1', NULL, 196
7757-
UNION ALL
7758-
SELECT 4, 'QUERY_OPTIMIZER_HOTFIXES', '0', NULL, 197
7759-
UNION ALL
7760-
SELECT 6, 'IDENTITY_CACHE', '1', NULL, 237
7761-
UNION ALL
7762-
SELECT 7, 'INTERLEAVED_EXECUTION_TVF', '1', NULL, 238
7763-
UNION ALL
7764-
SELECT 8, 'BATCH_MODE_MEMORY_GRANT_FEEDBACK', '1', NULL, 239
7765-
UNION ALL
7766-
SELECT 9, 'BATCH_MODE_ADAPTIVE_JOINS', '1', NULL, 240
7767-
UNION ALL
7768-
SELECT 10, 'TSQL_SCALAR_UDF_INLINING', '1', NULL, 241
7769-
UNION ALL
7770-
SELECT 11, 'ELEVATE_ONLINE', 'OFF', NULL, 242
7771-
UNION ALL
7772-
SELECT 12, 'ELEVATE_RESUMABLE', 'OFF', NULL, 243
7773-
UNION ALL
7774-
SELECT 13, 'OPTIMIZE_FOR_AD_HOC_WORKLOADS', '0', NULL, 244
7775-
UNION ALL
7776-
SELECT 14, 'XTP_PROCEDURE_EXECUTION_STATISTICS', '0', NULL, 245
7777-
UNION ALL
7778-
SELECT 15, 'XTP_QUERY_EXECUTION_STATISTICS', '0', NULL, 246
7779-
UNION ALL
7780-
SELECT 16, 'ROW_MODE_MEMORY_GRANT_FEEDBACK', '1', NULL, 247
7781-
UNION ALL
7782-
SELECT 17, 'ISOLATE_SECURITY_POLICY_CARDINALITY', '0', NULL, 248
7783-
UNION ALL
7784-
SELECT 18, 'BATCH_MODE_ON_ROWSTORE', '1', NULL, 249
7785-
UNION ALL
7786-
SELECT 19, 'DEFERRED_COMPILATION_TV', '1', NULL, 250
7787-
UNION ALL
7788-
SELECT 20, 'ACCELERATED_PLAN_FORCING', '1', NULL, 251
7789-
UNION ALL
7790-
SELECT 21, 'GLOBAL_TEMPORARY_TABLE_AUTO_DROP', '1', NULL, 252
7791-
UNION ALL
7792-
SELECT 22, 'LIGHTWEIGHT_QUERY_PROFILING', '1', NULL, 253
7793-
UNION ALL
7794-
SELECT 23, 'VERBOSE_TRUNCATION_WARNINGS', '1', NULL, 254
7795-
UNION ALL
7796-
SELECT 24, 'LAST_QUERY_PLAN_STATS', '0', NULL, 255;
7797-
EXEC dbo.sp_MSforeachdb 'USE [?]; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; INSERT INTO #BlitzResults (CheckID, DatabaseName, Priority, FindingsGroup, Finding, URL, Details)
7752+
VALUES
7753+
(1, 'MAXDOP', '0', NULL, 194),
7754+
(2, 'LEGACY_CARDINALITY_ESTIMATION', '0', NULL, 195),
7755+
(3, 'PARAMETER_SNIFFING', '1', NULL, 196),
7756+
(4, 'QUERY_OPTIMIZER_HOTFIXES', '0', NULL, 197),
7757+
(6, 'IDENTITY_CACHE', '1', NULL, 237),
7758+
(7, 'INTERLEAVED_EXECUTION_TVF', '1', NULL, 238),
7759+
(8, 'BATCH_MODE_MEMORY_GRANT_FEEDBACK', '1', NULL, 239),
7760+
(9, 'BATCH_MODE_ADAPTIVE_JOINS', '1', NULL, 240),
7761+
(10, 'TSQL_SCALAR_UDF_INLINING', '1', NULL, 241),
7762+
(11, 'ELEVATE_ONLINE', 'OFF', NULL, 242),
7763+
(12, 'ELEVATE_RESUMABLE', 'OFF', NULL, 243),
7764+
(13, 'OPTIMIZE_FOR_AD_HOC_WORKLOADS', '0', NULL, 244),
7765+
(14, 'XTP_PROCEDURE_EXECUTION_STATISTICS', '0', NULL, 245),
7766+
(15, 'XTP_QUERY_EXECUTION_STATISTICS', '0', NULL, 246),
7767+
(16, 'ROW_MODE_MEMORY_GRANT_FEEDBACK', '1', NULL, 247),
7768+
(17, 'ISOLATE_SECURITY_POLICY_CARDINALITY', '0', NULL, 248),
7769+
(18, 'BATCH_MODE_ON_ROWSTORE', '1', NULL, 249),
7770+
(19, 'DEFERRED_COMPILATION_TV', '1', NULL, 250),
7771+
(20, 'ACCELERATED_PLAN_FORCING', '1', NULL, 251),
7772+
(21, 'GLOBAL_TEMPORARY_TABLE_AUTO_DROP', '1', NULL, 252),
7773+
(22, 'LIGHTWEIGHT_QUERY_PROFILING', '1', NULL, 253),
7774+
(23, 'VERBOSE_TRUNCATION_WARNINGS', '1', NULL, 254),
7775+
(24, 'LAST_QUERY_PLAN_STATS', '0', NULL, 255),
7776+
(25, 'PAUSED_RESUMABLE_INDEX_ABORT_DURATION_MINUTES', '1440', NULL, 267),
7777+
(26, 'DW_COMPATIBILITY_LEVEL', '0', NULL, 267),
7778+
(27, 'EXEC_QUERY_STATS_FOR_SCALAR_FUNCTIONS', '1', NULL, 267),
7779+
(28, 'PARAMETER_SENSITIVE_PLAN_OPTIMIZATION', '1', NULL, 267),
7780+
(29, 'ASYNC_STATS_UPDATE_WAIT_AT_LOW_PRIORITY', '0', NULL, 267),
7781+
(31, 'CE_FEEDBACK', '1', NULL, 267),
7782+
(33, 'MEMORY_GRANT_FEEDBACK_PERSISTENCE', '1', NULL, 267),
7783+
(34, 'MEMORY_GRANT_FEEDBACK_PERCENTILE_GRANT', '1', NULL, 267),
7784+
(35, 'OPTIMIZED_PLAN_FORCING', '1', NULL, 267),
7785+
(37, 'DOP_FEEDBACK', '0', NULL, 267),
7786+
(38, 'LEDGER_DIGEST_STORAGE_ENDPOINT', 'OFF', NULL, 267),
7787+
(39, 'FORCE_SHOWPLAN_RUNTIME_PARAMETER_COLLECTION', '0', NULL, 267);
7788+
7789+
EXEC dbo.sp_MSforeachdb 'USE [?]; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; INSERT INTO #BlitzResults (CheckID, DatabaseName, Priority, FindingsGroup, Finding, URL, Details)
77987790
SELECT def1.CheckID, DB_NAME(), 210, ''Non-Default Database Scoped Config'', dsc.[name], ''https://www.brentozar.com/go/dbscope'', (''Set value: '' + COALESCE(CAST(dsc.value AS NVARCHAR(100)),''Empty'') + '' Default: '' + COALESCE(CAST(def1.default_value AS NVARCHAR(100)),''Empty'') + '' Set value for secondary: '' + COALESCE(CAST(dsc.value_for_secondary AS NVARCHAR(100)),''Empty'') + '' Default value for secondary: '' + COALESCE(CAST(def1.default_value_for_secondary AS NVARCHAR(100)),''Empty''))
77997791
FROM [?].sys.database_scoped_configurations dsc
78007792
INNER JOIN #DatabaseScopedConfigurationDefaults def1 ON dsc.configuration_id = def1.configuration_id

sp_BlitzIndex.sql

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ DECLARE @ColumnList NVARCHAR(MAX);
131131
DECLARE @ColumnListWithApostrophes NVARCHAR(MAX);
132132
DECLARE @PartitionCount INT;
133133
DECLARE @OptimizeForSequentialKey BIT = 0;
134+
DECLARE @ResumableIndexesDisappearAfter INT = 0;
134135
DECLARE @StringToExecute NVARCHAR(MAX);
135136

136137
/* If user was lazy and just used @ObjectName with a fully qualified table name, then lets parse out the various parts */
@@ -2612,7 +2613,17 @@ OPTION (RECOMPILE);';
26122613
[object_id], index_id, name, sql_text, last_max_dop_used, partition_number, state, state_desc,
26132614
start_time, last_pause_time, total_execution_time, percent_complete, page_count )
26142615
EXEC sp_executesql @dsql, @params = N'@i_DatabaseName NVARCHAR(128)', @i_DatabaseName = @DatabaseName;
2615-
END TRY
2616+
2617+
SET @dsql=N'SELECT @ResumableIndexesDisappearAfter = CAST(value AS INT)
2618+
FROM ' + QUOTENAME(@DatabaseName) + N'.sys.database_scoped_configurations
2619+
WHERE name = ''PAUSED_RESUMABLE_INDEX_ABORT_DURATION_MINUTES''
2620+
AND value > 0;'
2621+
EXEC sp_executesql @dsql, N'@ResumableIndexesDisappearAfter INT OUT', @ResumableIndexesDisappearAfter out;
2622+
2623+
IF @ResumableIndexesDisappearAfter IS NULL
2624+
SET @ResumableIndexesDisappearAfter = 0;
2625+
2626+
END TRY
26162627
BEGIN CATCH
26172628
RAISERROR (N'Skipping #IndexResumableOperations population due to error, typically low permissions', 0,1) WITH NOWAIT;
26182629
END CATCH
@@ -3294,29 +3305,34 @@ BEGIN
32943305
SELECT
32953306
N'Resumable Index Operation' AS finding,
32963307
N'This may invalidate your analysis!' AS warning,
3297-
iro.state_desc + ' on ' + iro.db_schema_table_index +
3308+
iro.state_desc + N' on ' + iro.db_schema_table_index +
32983309
CASE iro.state
32993310
WHEN 0 THEN
3300-
' at MAXDOP ' + CONVERT(NVARCHAR(30), iro.last_max_dop_used) +
3301-
'. First started ' + CONVERT(NVARCHAR(50), iro.start_time, 120) + '. ' +
3302-
CONVERT(NVARCHAR(6), CONVERT(MONEY, iro.percent_complete)) + '% complete after ' +
3311+
N' at MAXDOP ' + CONVERT(NVARCHAR(30), iro.last_max_dop_used) +
3312+
N'. First started ' + CONVERT(NVARCHAR(50), iro.start_time, 120) + N'. ' +
3313+
CONVERT(NVARCHAR(6), CONVERT(MONEY, iro.percent_complete)) + N'% complete after ' +
33033314
CONVERT(NVARCHAR(30), iro.total_execution_time) +
3304-
' minute(s). This blocks DDL and can pile up ghosts.'
3315+
N' minute(s). ' +
3316+
CASE WHEN @ResumableIndexesDisappearAfter > 0
3317+
THEN N' Will be automatically removed by the database server at ' + CONVERT(NVARCHAR(50), (DATEADD(mi, @ResumableIndexesDisappearAfter, iro.last_pause_time)), 121) + N'. '
3318+
ELSE N' Will not be automatically removed by the database server. '
3319+
END
3320+
+ N'This blocks DDL and can pile up ghosts.'
33053321
WHEN 1 THEN
3306-
' since ' + CONVERT(NVARCHAR(50), iro.last_pause_time, 120) + '. ' +
3307-
CONVERT(NVARCHAR(6), CONVERT(MONEY, iro.percent_complete)) + '% complete' +
3322+
N' since ' + CONVERT(NVARCHAR(50), iro.last_pause_time, 120) + N'. ' +
3323+
CONVERT(NVARCHAR(6), CONVERT(MONEY, iro.percent_complete)) + N'% complete' +
33083324
/*
33093325
At 100% completion, resumable indexes open up a transaction and go back to paused for what ought to be a moment.
33103326
Updating statistics is one of the things that it can do in this false paused state.
33113327
Updating stats can take a while, so we point it out as a likely delay.
33123328
It seems that any of the normal operations that happen at the very end of an index build can cause this.
33133329
*/
33143330
CASE WHEN iro.percent_complete > 99.9
3315-
THEN '. It is probably still running, perhaps updating statistics.'
3316-
ELSE ' after ' + CONVERT(NVARCHAR(30), iro.total_execution_time)
3317-
+ ' minute(s). This blocks DDL, fails transactions needing table-level X locks, and can pile up ghosts.'
3331+
THEN N'. It is probably still running, perhaps updating statistics.'
3332+
ELSE N' after ' + CONVERT(NVARCHAR(30), iro.total_execution_time)
3333+
+ N' minute(s). This blocks DDL, fails transactions needing table-level X locks, and can pile up ghosts.'
33183334
END
3319-
ELSE ' which is an undocumented resumable index state description.'
3335+
ELSE N' which is an undocumented resumable index state description.'
33203336
END AS details,
33213337
N'https://www.BrentOzar.com/go/resumable' AS URL,
33223338
iro.more_info AS [More Info]
@@ -3738,25 +3754,29 @@ BEGIN
37383754
N'Resumable Index Operation Paused' AS finding,
37393755
iro.[database_name] AS [Database Name],
37403756
N'https://www.BrentOzar.com/go/resumable' AS URL,
3741-
iro.state_desc + ' on ' + iro.db_schema_table_index +
3742-
' since ' + CONVERT(NVARCHAR(50), iro.last_pause_time, 120) + '. ' +
3743-
CONVERT(NVARCHAR(6), CONVERT(MONEY, iro.percent_complete)) + '% complete' +
3757+
iro.state_desc + N' on ' + iro.db_schema_table_index +
3758+
N' since ' + CONVERT(NVARCHAR(50), iro.last_pause_time, 120) + N'. ' +
3759+
CONVERT(NVARCHAR(6), CONVERT(MONEY, iro.percent_complete)) + N'% complete' +
37443760
/*
37453761
At 100% completion, resumable indexes open up a transaction and go back to paused for what ought to be a moment.
37463762
Updating statistics is one of the things that it can do in this false paused state.
37473763
Updating stats can take a while, so we point it out as a likely delay.
37483764
It seems that any of the normal operations that happen at the very end of an index build can cause this.
37493765
*/
37503766
CASE WHEN iro.percent_complete > 99.9
3751-
THEN '. It is probably still running, perhaps updating statistics.'
3752-
ELSE ' after ' + CONVERT(NVARCHAR(30), iro.total_execution_time)
3753-
+ ' minute(s). This blocks DDL, fails transactions needing table-level X locks, and can pile up ghosts.'
3767+
THEN N'. It is probably still running, perhaps updating statistics.'
3768+
ELSE N' after ' + CONVERT(NVARCHAR(30), iro.total_execution_time)
3769+
+ N' minute(s). This blocks DDL, fails transactions needing table-level X locks, and can pile up ghosts. '
3770+
END +
3771+
CASE WHEN @ResumableIndexesDisappearAfter > 0
3772+
THEN N' Will be automatically removed by the database server at ' + CONVERT(NVARCHAR(50), (DATEADD(mi, @ResumableIndexesDisappearAfter, iro.last_pause_time)), 121) + N'. '
3773+
ELSE N' Will not be automatically removed by the database server. '
37543774
END AS details,
3755-
'Old index: ' + ISNULL(i.index_definition, 'not found. Either the index is new or you need @IncludeInactiveIndexes = 1') AS index_definition,
3775+
N'Old index: ' + ISNULL(i.index_definition, N'not found. Either the index is new or you need @IncludeInactiveIndexes = 1') AS index_definition,
37563776
i.secret_columns,
37573777
i.index_usage_summary,
3758-
'New index: ' + iro.reserved_MB_pretty_print + '; Old index: ' + ISNULL(sz.index_size_summary,'not found.') AS index_size_summary,
3759-
'New index: ' + iro.sql_text AS create_tsql,
3778+
N'New index: ' + iro.reserved_MB_pretty_print + N'; Old index: ' + ISNULL(sz.index_size_summary,'not found.') AS index_size_summary,
3779+
N'New index: ' + iro.sql_text AS create_tsql,
37603780
iro.more_info
37613781
FROM #IndexResumableOperations iro
37623782
LEFT JOIN #IndexSanity AS i ON i.database_id = iro.database_id

0 commit comments

Comments
 (0)