1
+
1
2
-- SQL Managed Instance Diagnostic Information Queries
2
3
-- Glenn Berry
3
- -- Last Modified: September 1 , 2020
4
+ -- Last Modified: December 3 , 2020
4
5
-- https://glennsqlperformance.com/
5
6
-- https://sqlserverperformance.wordpress.com/
6
7
-- YouTube: https://bit.ly/2PkoAM1
@@ -333,7 +334,6 @@ ORDER BY vs.volume_mount_point OPTION (RECOMPILE);
333
334
334
335
335
336
-- Drive level latency information (Query 14) (Drive Level Latency)
336
- -- Based on code from Jimmy May
337
337
SELECT tab.[Drive], tab .volume_mount_point AS [Volume Mount Point],
338
338
CASE
339
339
WHEN num_of_reads = 0 THEN 0
@@ -443,18 +443,25 @@ db.[compatibility_level] AS [DB Compatibility Level],
443
443
db .is_mixed_page_allocation_on , db .page_verify_option_desc AS [Page Verify Option],
444
444
db .is_auto_create_stats_on , db .is_auto_update_stats_on , db .is_auto_update_stats_async_on , db .is_parameterization_forced ,
445
445
db .snapshot_isolation_state_desc , db .is_read_committed_snapshot_on , db .is_auto_close_on , db .is_auto_shrink_on ,
446
- db .target_recovery_time_in_seconds , db .is_cdc_enabled ,
447
- db .delayed_durability_desc , db .is_auto_create_stats_incremental_on ,
448
- db .is_query_store_on , db .is_sync_with_backup , db .is_temporal_history_retention_enabled ,
449
- db .is_supplemental_logging_enabled ,
450
- db .is_encrypted , de .encryption_state , de .percent_complete , de .key_algorithm , de .key_length , db .resource_pool_id ,
451
- db .is_tempdb_spill_to_remote_store , db .is_result_set_caching_on , db .is_accelerated_database_recovery_on
446
+ db .target_recovery_time_in_seconds , db .is_cdc_enabled , db .delayed_durability_desc ,
447
+ db .is_query_store_on , db .is_sync_with_backup , db .is_temporal_history_retention_enabled ,
448
+ db .is_encrypted , de .encryption_state , de .percent_complete , de .key_algorithm , de .key_length ,
449
+ db .is_accelerated_database_recovery_on
452
450
FROM sys .databases AS db WITH (NOLOCK )
453
451
LEFT OUTER JOIN sys .dm_database_encryption_keys AS de WITH (NOLOCK )
454
452
ON db .database_id = de .database_id
455
453
ORDER BY db.[name] OPTION (RECOMPILE );
456
454
-- ----
457
455
456
+ -- sys.databases (Transact-SQL)
457
+ -- https://bit.ly/2G5wqaX
458
+
459
+ -- sys.dm_os_performance_counters (Transact-SQL)
460
+ -- https://bit.ly/3kEO2JR
461
+
462
+ -- sys.dm_database_encryption_keys (Transact-SQL)
463
+ -- https://bit.ly/3mE7kkx
464
+
458
465
-- Things to look at:
459
466
-- How many databases are on the instance?
460
467
-- What recovery models are they using?
@@ -826,7 +833,7 @@ AND counter_name = N'Page life expectancy' OPTION (RECOMPILE);
826
833
-- Higher PLE is better. Watch the trend over time, not the absolute value
827
834
-- This will only return one row for non-NUMA systems
828
835
829
- -- Page Life Expectancy isnt what you think
836
+ -- Page Life Expectancy isnt what you think
830
837
-- https://bit.ly/2EgynLa
831
838
832
839
@@ -1450,7 +1457,8 @@ ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE);
1450
1457
1451
1458
1452
1459
-- - Index Read/Write stats (all tables in current DB) ordered by Reads (Query 59) (Overall Index Usage - Reads)
1453
- SELECT OBJECT_NAME (i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i .index_id ,
1460
+ SELECT SCHEMA_NAME (t.[schema_id]) AS [SchemaName], OBJECT_NAME (i.[object_id]) AS [ObjectName],
1461
+ i.[name] AS [IndexName], i .index_id ,
1454
1462
s .user_seeks , s .user_scans , s .user_lookups ,
1455
1463
s .user_seeks + s .user_scans + s .user_lookups AS [Total Reads],
1456
1464
s .user_updates AS [Writes],
@@ -1461,6 +1469,8 @@ LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK)
1461
1469
ON i.[object_id] = s.[object_id]
1462
1470
AND i .index_id = s .index_id
1463
1471
AND s .database_id = DB_ID ()
1472
+ LEFT OUTER JOIN sys .tables AS t WITH (NOLOCK )
1473
+ ON t.[object_id] = i.[object_id]
1464
1474
WHERE OBJECTPROPERTY (i.[object_id],' IsUserTable' ) = 1
1465
1475
ORDER BY s .user_seeks + s .user_scans + s .user_lookups DESC OPTION (RECOMPILE ); -- Order by reads
1466
1476
-- ----
@@ -1469,7 +1479,8 @@ ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -
1469
1479
1470
1480
1471
1481
-- - Index Read/Write stats (all tables in current DB) ordered by Writes (Query 60) (Overall Index Usage - Writes)
1472
- SELECT OBJECT_NAME (i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i .index_id ,
1482
+ SELECT SCHEMA_NAME (t.[schema_id]) AS [SchemaName],OBJECT_NAME (i.[object_id]) AS [ObjectName],
1483
+ i.[name] AS [IndexName], i .index_id ,
1473
1484
s .user_updates AS [Writes], s .user_seeks + s .user_scans + s .user_lookups AS [Total Reads],
1474
1485
i.[type_desc] AS [Index Type], i .fill_factor AS [Fill Factor], i .has_filter , i .filter_definition ,
1475
1486
s .last_system_update , s .last_user_update
@@ -1478,9 +1489,10 @@ LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK)
1478
1489
ON i.[object_id] = s.[object_id]
1479
1490
AND i .index_id = s .index_id
1480
1491
AND s .database_id = DB_ID ()
1492
+ LEFT OUTER JOIN sys .tables AS t WITH (NOLOCK )
1493
+ ON t.[object_id] = i.[object_id]
1481
1494
WHERE OBJECTPROPERTY (i.[object_id],' IsUserTable' ) = 1
1482
1495
ORDER BY s .user_updates DESC OPTION (RECOMPILE ); -- Order by writes
1483
- -- ----
1484
1496
1485
1497
-- Show which indexes in the current database are most active for Writes
1486
1498
@@ -1654,30 +1666,10 @@ ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE);
1654
1666
-- https://bit.ly/28Rpb2x
1655
1667
1656
1668
1657
- -- These six Pluralsight Courses go into more detail about how to run these queries and interpret the results
1658
-
1659
- -- Azure SQL Database: Diagnosing Performance Issues with DMVs
1660
- -- https://bit.ly/2meDRCN
1661
-
1662
- -- SQL Server 2017: Diagnosing Performance Issues with DMVs
1663
- -- https://bit.ly/2FqCeti
1664
-
1665
- -- SQL Server 2017: Diagnosing Configuration Issues with DMVs
1666
- -- https://bit.ly/2MSUDUL
1667
-
1668
- -- SQL Server 2014 DMV Diagnostic Queries Part 1
1669
- -- https://bit.ly/2plxCer
1670
-
1671
- -- SQL Server 2014 DMV Diagnostic Queries Part 2
1672
- -- https://bit.ly/2IuJpzI
1673
-
1674
- -- SQL Server 2014 DMV Diagnostic Queries Part 3
1675
- -- https://bit.ly/2FIlCPb
1676
-
1677
-
1678
-
1679
1669
-- Microsoft Visual Studio Dev Essentials
1680
1670
-- https://bit.ly/2qjNRxi
1681
1671
1682
1672
-- Microsoft Azure Learn
1683
- -- https://bit.ly/2O0Hacc
1673
+ -- https://bit.ly/2O0Hacc
1674
+
1675
+
0 commit comments