Skip to content

Commit 20f098c

Browse files
Corrected compilations to optimizations
1 parent 588d02d commit 20f098c

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

sqldb-tips/get-sqldb-tips-compat-level-100-only.sql

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ DECLARE
175175
-- 1420: The minumum number of blocked tasks observed at the time of each 20-second snapshot to be considered significant
176176
@LockBlockingBlockedTaskThreshold int = 1,
177177

178-
-- 1430: The minimum number of requests in an interval to start considering if query compilations are high
179-
@QueryCompilationRequestCountThreshold smallint = 100,
178+
-- 1430: The minimum number of requests in an interval to start considering if query optimizations are high
179+
@QueryOptimizationRequestCountThreshold smallint = 100,
180180

181-
-- 1430: The minimum ratio of query compilations (optimizations) to the number of requests to be considered significant
182-
@QueryCompilationRequestThresholdRatio decimal(3,2) = 0.15,
181+
-- 1430: The minimum ratio of query optimizations to the number of requests to be considered significant
182+
@QueryOptimizationRequestThresholdRatio decimal(3,2) = 0.15,
183183

184184
-- 1450: The minimum local storage usage ratio to be considered significant
185185
@MinLocalStorageQuotaUsageRatio decimal(3,2) = 0.85,
@@ -310,7 +310,7 @@ VALUES
310310
(1, 1400, 'Some statistics may be out of date', 70, 'https://aka.ms/sqldbtipswiki#tip_id-1400', 'VIEW DATABASE STATE'),
311311
(1, 1410, 'Many tables do not have any indexes', 60, 'https://aka.ms/sqldbtipswiki#tip_id-1410', 'VIEW DATABASE STATE'),
312312
(1, 1420, 'Significant lock blocking has recently occurred', 70, 'https://aka.ms/sqldbtipswiki#tip_id-1420', 'VIEW SERVER STATE'),
313-
(1, 1430, 'The number of recent query compilations is high', 80, 'https://aka.ms/sqldbtipswiki#tip_id-1430', 'VIEW SERVER STATE'),
313+
(1, 1430, 'The number of recent query optimizations is high', 80, 'https://aka.ms/sqldbtipswiki#tip_id-1430', 'VIEW SERVER STATE'),
314314
(1, 1440, 'Row locks or page locks are disabled for some indexes', 90, 'https://aka.ms/sqldbtipswiki#tip_id-1440', 'VIEW DATABASE STATE'),
315315
(1, 1450, 'Allocated local storage is close to maximum local storage', 90, 'https://aka.ms/sqldbtipswiki#tip_id-1450', 'VIEW SERVER STATE'),
316316
(1, 1460, 'Column collation does not match database collation', 70, 'https://aka.ms/sqldbtipswiki#tip_id-1460', 'VIEW DATABASE STATE'),
@@ -3872,68 +3872,68 @@ FROM packed_blocking_snapshot
38723872
HAVING COUNT(1) > 0
38733873
;
38743874

3875-
-- High query compilations
3875+
-- High query optimizations
38763876
IF EXISTS (SELECT 1 FROM @TipDefinition WHERE tip_id IN (1430) AND execute_indicator = 1)
38773877

38783878
WITH
3879-
high_compilation_snapshot AS
3879+
high_optimizations_snapshot AS
38803880
(
38813881
SELECT snapshot_time,
38823882
duration_ms,
38833883
delta_request_count,
38843884
delta_query_optimizations,
3885-
IIF(delta_query_optimizations > @QueryCompilationRequestThresholdRatio * delta_request_count AND delta_request_count >= @QueryCompilationRequestCountThreshold, 1, 0) AS high_compilation_indicator
3885+
IIF(delta_query_optimizations > @QueryOptimizationRequestThresholdRatio * delta_request_count AND delta_request_count >= @QueryOptimizationRequestCountThreshold, 1, 0) AS high_optimizations_indicator
38863886
FROM sys.dm_resource_governor_workload_groups_history_ex
38873887
WHERE @EngineEdition = 5
38883888
AND
38893889
name like 'UserPrimaryGroup.DB%'
38903890
AND
38913891
TRY_CAST(RIGHT(name, LEN(name) - LEN('UserPrimaryGroup.DB') - 2) AS int) = DB_ID()
38923892
),
3893-
pre_packed_high_compilation_snapshot AS
3893+
pre_packed_high_optimizations_snapshot AS
38943894
(
38953895
SELECT snapshot_time,
38963896
duration_ms,
38973897
delta_request_count,
38983898
delta_query_optimizations,
3899-
high_compilation_indicator,
3899+
high_optimizations_indicator,
39003900
ROW_NUMBER() OVER (ORDER BY snapshot_time)
39013901
-
3902-
SUM(high_compilation_indicator) OVER (ORDER BY snapshot_time ROWS UNBOUNDED PRECEDING)
3902+
SUM(high_optimizations_indicator) OVER (ORDER BY snapshot_time ROWS UNBOUNDED PRECEDING)
39033903
AS grouping_helper
3904-
FROM high_compilation_snapshot
3904+
FROM high_optimizations_snapshot
39053905
),
3906-
packed_high_compilation_snapshot AS
3906+
packed_high_optimization_snapshot AS
39073907
(
39083908
SELECT MIN(snapshot_time) AS min_snapshot_time,
39093909
MAX(snapshot_time) AS max_snapshot_time,
39103910
AVG(duration_ms) AS avg_snapshot_interval_duration_ms,
39113911
SUM(delta_request_count) AS total_requests,
3912-
SUM(delta_query_optimizations) AS total_compilations
3913-
FROM pre_packed_high_compilation_snapshot
3914-
WHERE high_compilation_indicator = 1
3912+
SUM(delta_query_optimizations) AS total_optimizations
3913+
FROM pre_packed_high_optimizations_snapshot
3914+
WHERE high_optimizations_indicator = 1
39153915
GROUP BY grouping_helper
39163916
)
39173917
INSERT INTO @DetectedTip (tip_id, details)
39183918
SELECT 1430 AS tip_id,
39193919
CONCAT(
39203920
@NbspCRLF,
3921-
'Time intervals with a high number of query compilations (UTC):',
3921+
'Time intervals with a high number of query optimizations (UTC):',
39223922
@CRLF, @CRLF,
39233923
STRING_AGG(
39243924
CAST(CONCAT(
39253925
'Interval start time: ', FORMAT(DATEADD(millisecond, -avg_snapshot_interval_duration_ms, min_snapshot_time), 's'),
39263926
', end time: ', FORMAT(max_snapshot_time, 's'),
39273927
', duration: ', DATEADD(second, DATEDIFF(second, DATEADD(millisecond, -avg_snapshot_interval_duration_ms, min_snapshot_time), max_snapshot_time), CAST('00:00:00' AS time(0))),
39283928
', total requests: ', FORMAT(total_requests, '#,0'),
3929-
', total compilations: ', FORMAT(total_compilations, '#,0'),
3930-
', query compilation rate: ', FORMAT(LEAST(total_compilations * 1.0 / total_requests, 1), 'P')
3929+
', total optimizations: ', FORMAT(total_optimizations, '#,0'),
3930+
', query optimization rate: ', FORMAT(LEAST(total_optimizations * 1.0 / total_requests, 1), 'P')
39313931
) AS nvarchar(max)), @CRLF
39323932
),
39333933
@CRLF
39343934
)
39353935
AS details
3936-
FROM packed_high_compilation_snapshot
3936+
FROM packed_high_optimization_snapshot
39373937
HAVING COUNT(1) > 0
39383938
;
39393939

sqldb-tips/get-sqldb-tips.sql

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ DECLARE
172172
-- 1420: The minumum number of blocked tasks observed at the time of each 20-second snapshot to be considered significant
173173
@LockBlockingBlockedTaskThreshold int = 1,
174174

175-
-- 1430: The minimum number of requests in an interval to start considering if query compilations are high
176-
@QueryCompilationRequestCountThreshold smallint = 100,
175+
-- 1430: The minimum number of requests in an interval to start considering if query optimizations are high
176+
@QueryOptimizationRequestCountThreshold smallint = 100,
177177

178-
-- 1430: The minimum ratio of query compilations (optimizations) to the number of requests to be considered significant
179-
@QueryCompilationRequestThresholdRatio decimal(3,2) = 0.15,
178+
-- 1430: The minimum ratio of query optimizations to the number of requests to be considered significant
179+
@QueryOptimizationRequestThresholdRatio decimal(3,2) = 0.15,
180180

181181
-- 1450: The minimum local storage usage ratio to be considered significant
182182
@MinLocalStorageQuotaUsageRatio decimal(3,2) = 0.85,
@@ -298,7 +298,7 @@ VALUES
298298
(1, 1400, 'Some statistics may be out of date', 70, 'https://aka.ms/sqldbtipswiki#tip_id-1400', 'VIEW DATABASE STATE'),
299299
(1, 1410, 'Many tables do not have any indexes', 60, 'https://aka.ms/sqldbtipswiki#tip_id-1410', 'VIEW DATABASE STATE'),
300300
(1, 1420, 'Significant lock blocking has recently occurred', 70, 'https://aka.ms/sqldbtipswiki#tip_id-1420', 'VIEW SERVER STATE'),
301-
(1, 1430, 'The number of recent query compilations is high', 80, 'https://aka.ms/sqldbtipswiki#tip_id-1430', 'VIEW SERVER STATE'),
301+
(1, 1430, 'The number of recent query optimizations is high', 80, 'https://aka.ms/sqldbtipswiki#tip_id-1430', 'VIEW SERVER STATE'),
302302
(1, 1440, 'Row locks or page locks are disabled for some indexes', 90, 'https://aka.ms/sqldbtipswiki#tip_id-1440', 'VIEW DATABASE STATE'),
303303
(1, 1450, 'Allocated local storage is close to maximum local storage', 90, 'https://aka.ms/sqldbtipswiki#tip_id-1450', 'VIEW SERVER STATE'),
304304
(1, 1460, 'Column collation does not match database collation', 70, 'https://aka.ms/sqldbtipswiki#tip_id-1460', 'VIEW DATABASE STATE'),
@@ -3872,69 +3872,69 @@ FROM packed_blocking_snapshot
38723872
HAVING COUNT(1) > 0
38733873
;
38743874

3875-
-- High query compilations
3875+
-- High query optimizations
38763876
IF EXISTS (SELECT 1 FROM @TipDefinition WHERE tip_id IN (1430) AND execute_indicator = 1)
38773877

38783878
WITH
3879-
high_compilation_snapshot AS
3879+
high_optimizations_snapshot AS
38803880
(
38813881
SELECT snapshot_time,
38823882
duration_ms,
38833883
delta_request_count,
38843884
delta_query_optimizations,
3885-
IIF(delta_query_optimizations > @QueryCompilationRequestThresholdRatio * delta_request_count AND delta_request_count >= @QueryCompilationRequestCountThreshold, 1, 0) AS high_compilation_indicator
3885+
IIF(delta_query_optimizations > @QueryOptimizationRequestThresholdRatio * delta_request_count AND delta_request_count >= @QueryOptimizationRequestCountThreshold, 1, 0) AS high_optimizations_indicator
38863886
FROM sys.dm_resource_governor_workload_groups_history_ex
38873887
WHERE @EngineEdition = 5
38883888
AND
38893889
name like 'UserPrimaryGroup.DB%'
38903890
AND
38913891
TRY_CAST(RIGHT(name, LEN(name) - LEN('UserPrimaryGroup.DB') - 2) AS int) = DB_ID()
38923892
),
3893-
pre_packed_high_compilation_snapshot AS
3893+
pre_packed_high_optimizations_snapshot AS
38943894
(
38953895
SELECT snapshot_time,
38963896
duration_ms,
38973897
delta_request_count,
38983898
delta_query_optimizations,
3899-
high_compilation_indicator,
3899+
high_optimizations_indicator,
39003900
ROW_NUMBER() OVER (ORDER BY snapshot_time)
39013901
-
3902-
SUM(high_compilation_indicator) OVER (ORDER BY snapshot_time ROWS UNBOUNDED PRECEDING)
3902+
SUM(high_optimizations_indicator) OVER (ORDER BY snapshot_time ROWS UNBOUNDED PRECEDING)
39033903
AS grouping_helper
3904-
FROM high_compilation_snapshot
3904+
FROM high_optimizations_snapshot
39053905
),
3906-
packed_high_compilation_snapshot AS
3906+
packed_high_optimization_snapshot AS
39073907
(
39083908
SELECT MIN(snapshot_time) AS min_snapshot_time,
39093909
MAX(snapshot_time) AS max_snapshot_time,
39103910
AVG(duration_ms) AS avg_snapshot_interval_duration_ms,
39113911
SUM(delta_request_count) AS total_requests,
3912-
SUM(delta_query_optimizations) AS total_compilations
3913-
FROM pre_packed_high_compilation_snapshot
3914-
WHERE high_compilation_indicator = 1
3912+
SUM(delta_query_optimizations) AS total_optimizations
3913+
FROM pre_packed_high_optimizations_snapshot
3914+
WHERE high_optimizations_indicator = 1
39153915
GROUP BY grouping_helper
39163916
)
39173917
INSERT INTO @DetectedTip (tip_id, details)
39183918
SELECT 1430 AS tip_id,
39193919
CONCAT(
39203920
@NbspCRLF,
3921-
'Time intervals with a high number of query compilations (UTC):',
3921+
'Time intervals with a high number of query optimizations (UTC):',
39223922
@CRLF, @CRLF,
39233923
STRING_AGG(
39243924
CAST(CONCAT(
39253925
'Interval start time: ', FORMAT(DATEADD(millisecond, -avg_snapshot_interval_duration_ms, min_snapshot_time), 's'),
39263926
', end time: ', FORMAT(max_snapshot_time, 's'),
39273927
', duration: ', DATEADD(second, DATEDIFF(second, DATEADD(millisecond, -avg_snapshot_interval_duration_ms, min_snapshot_time), max_snapshot_time), CAST('00:00:00' AS time(0))),
39283928
', total requests: ', FORMAT(total_requests, '#,0'),
3929-
', total compilations: ', FORMAT(total_compilations, '#,0'),
3930-
', query compilation rate: ', FORMAT(LEAST(total_compilations * 1.0 / total_requests, 1), 'P')
3929+
', total optimizations: ', FORMAT(total_optimizations, '#,0'),
3930+
', query optimization rate: ', FORMAT(LEAST(total_optimizations * 1.0 / total_requests, 1), 'P')
39313931
) AS nvarchar(max)), @CRLF
39323932
)
39333933
WITHIN GROUP (ORDER BY min_snapshot_time DESC),
39343934
@CRLF
39353935
)
39363936
AS details
3937-
FROM packed_high_compilation_snapshot
3937+
FROM packed_high_optimization_snapshot
39383938
HAVING COUNT(1) > 0
39393939
;
39403940

0 commit comments

Comments
 (0)