Skip to content

Commit 20a76a1

Browse files
committed
Update SQL Server 2019 Diagnostic Information Queries
1 parent 24ae233 commit 20a76a1

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

Scripts/SQL Server 2019 Diagnostic Information Queries.sql

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
-- SQL Server 2019 Diagnostic Information Queries
33
-- Glenn Berry
4-
-- Last Modified: April 2, 2020
4+
-- Last Modified: May 3, 2020
55
-- https://glennsqlperformance.com/
66
-- https://sqlserverperformance.wordpress.com/
77
-- Twitter: GlennAlanBerry
@@ -286,7 +286,7 @@ ORDER BY sj.name OPTION (RECOMPILE);
286286
-- MSDN sysjobs documentation
287287
-- https://bit.ly/2paDEOP
288288

289-
-- SQL Server Maintenance Solution
289+
-- SQL Server Maintenance Solution (Ola Hallengren)
290290
-- https://bit.ly/1pgchQu
291291

292292
-- You can use this script to add default schedules to the standard Ola Hallengren Maintenance Solution jobs
@@ -409,7 +409,7 @@ FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE);
409409
-- You will see no results if your instance is not using AlwaysOn AGs
410410

411411

412-
-- Good overview of AG health and status (Query 16) (AlwaysOn AG Status)
412+
-- Good overview of AG health and status (Query 16) (AG Status)
413413
SELECT ag.name AS [AG Name], ar.replica_server_name, ar.availability_mode_desc, adc.[database_name],
414414
drs.is_local, drs.is_primary_replica, drs.synchronization_state_desc, drs.is_commit_participant,
415415
drs.synchronization_health_desc, drs.recovery_lsn, drs.truncation_lsn, drs.last_sent_lsn,
@@ -761,7 +761,8 @@ ORDER BY db.[name] OPTION (RECOMPILE);
761761
-- What compatibility level are the databases on?
762762
-- What is the Page Verify Option? (should be CHECKSUM)
763763
-- Is Auto Update Statistics Asynchronously enabled?
764-
-- Is Delayed Durability enabled
764+
-- What is target_recovery_time_in_seconds?
765+
-- Is Delayed Durability enabled?
765766
-- Make sure auto_shrink and auto_close are not enabled!
766767

767768
-- is_mixed_page_allocation_on is a new property for SQL Server 2016. Equivalent to TF 1118 for a user database
@@ -1150,13 +1151,13 @@ ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE);
11501151

11511152
-- MEMORYCLERK_SQLBUFFERPOOL was new for SQL Server 2012. It should be your highest consumer of memory
11521153

1153-
-- CACHESTORE_SQLCP SQL Plans
1154+
-- CACHESTORE_SQLCP - SQL Plans
11541155
-- These are cached SQL statements or batches that aren't in stored procedures, functions and triggers
11551156
-- Watch out for high values for CACHESTORE_SQLCP
11561157
-- Enabling 'optimize for ad hoc workloads' at the instance level can help reduce this
11571158
-- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this
11581159

1159-
-- CACHESTORE_OBJCP Object Plans
1160+
-- CACHESTORE_OBJCP - Object Plans
11601161
-- These are compiled plans for stored procedures, functions and triggers
11611162

11621163
-- sys.dm_os_memory_clerks (Transact-SQL)
@@ -1354,7 +1355,7 @@ ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE);
13541355
------
13551356

13561357
-- This helps you characterize your workload better from an I/O perspective for this database
1357-
-- It helps you determine whether you has an OLTP or DW/DSS type of workload
1358+
-- It helps you determine whether you have an OLTP or DW/DSS type of workload
13581359

13591360

13601361

@@ -1376,6 +1377,10 @@ WHERE t.dbid = DB_ID()
13761377
ORDER BY qs.execution_count DESC OPTION (RECOMPILE);
13771378
------
13781379

1380+
-- Tells you which cached queries are called the most often
1381+
-- This helps you characterize and baseline your workload
1382+
-- It also helps you find possible caching opportunities
1383+
13791384

13801385
-- Queries 57 through 62 are the "Bad Man List" for stored procedures
13811386

@@ -1400,6 +1405,7 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE);
14001405

14011406
-- Tells you which cached stored procedures are called the most often
14021407
-- This helps you characterize and baseline your workload
1408+
-- It also helps you find possible caching opportunities
14031409

14041410

14051411
-- Top Cached SPs By Avg Elapsed Time (Query 58) (SP Avg Elapsed Time)
@@ -1959,12 +1965,14 @@ AND bs.[type] = 'D' -- Change to L if you want Log backups
19591965
ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE);
19601966
------
19611967

1968+
-- Things to look at:
19621969
-- Are your backup sizes and times changing over time?
19631970
-- Are you using backup compression?
19641971
-- Are you using backup checksums?
19651972
-- Are you doing copy_only backups?
19661973
-- Are you doing encrypted backups?
19671974
-- Have you done any backup tuning with striped backups, or changing the parameters of the backup command?
1975+
-- Where are the backups going to?
19681976

19691977
-- In SQL Server 2016, native SQL Server backup compression actually works
19701978
-- much better with databases that are using TDE than in previous versions
@@ -2000,5 +2008,3 @@ ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE);
20002008
-- Microsoft Azure Learn
20012009
-- https://bit.ly/2O0Hacc
20022010

2003-
-- August 2017 blog series about upgrading and migrating to SQL Server 2016/2017
2004-
-- https://bit.ly/2ftKVrX

0 commit comments

Comments
 (0)