|
1 | 1 |
|
2 | 2 | -- SQL Server 2012 Diagnostic Information Queries |
3 | 3 | -- Glenn Berry |
4 | | --- July 2017 |
5 | | --- Last Modified: July 7, 2017 |
| 4 | +-- August 2017 |
| 5 | +-- Last Modified: August 7, 2017 |
6 | 6 | -- https://www.sqlskills.com/blogs/glenn/ |
7 | 7 | -- http://sqlserverperformance.wordpress.com/ |
8 | 8 | -- Twitter: GlennAlanBerry |
@@ -87,8 +87,7 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In |
87 | 87 | -- 11.0.6594 SP3 CU8 3/20/2017 |
88 | 88 | -- 11.0.6598 SP3 CU9 5/15/2017 |
89 | 89 | -- |
90 | | --- Announcing updates to the SQL Server Incremental Servicing Model (ISM) |
91 | | --- https://blogs.msdn.microsoft.com/sqlreleaseservices/announcing-updates-to-the-sql-server-incremental-servicing-model-ism/ |
| 90 | + |
92 | 91 |
|
93 | 92 | -- How to determine the version, edition and update level of SQL Server and its components |
94 | 93 | -- https://support.microsoft.com/en-us/kb/321185 |
@@ -123,7 +122,11 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In |
123 | 122 | -- Performance Related Fixes in Post-SQL Server 2012 RTM Builds |
124 | 123 | -- https://www.sqlskills.com/blogs/glenn/performance-related-fixes-in-post-sql-server-2012-rtm-builds/ |
125 | 124 |
|
| 125 | +-- Announcing updates to the SQL Server Incremental Servicing Model (ISM) |
| 126 | +-- https://blogs.msdn.microsoft.com/sqlreleaseservices/announcing-updates-to-the-sql-server-incremental-servicing-model-ism/ |
126 | 127 |
|
| 128 | +-- Download SQL Server Management Studio (SSMS) |
| 129 | +-- https://msdn.microsoft.com/en-us/library/mt238290.aspx |
127 | 130 |
|
128 | 131 |
|
129 | 132 | -- Get socket, physical core and logical core count from the SQL Server Error log. (Query 2) (Core Counts) |
@@ -212,7 +215,7 @@ DBCC TRACESTATUS (-1); |
212 | 215 | -- http://blogs.msdn.com/b/saponsqlserver/archive/2011/09/07/changes-to-automatic-update-statistics-in-sql-server-traceflag-2371.aspx |
213 | 216 |
|
214 | 217 | -- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log |
215 | | --- http://www.sqlskills.com/blogs/paul/fed-up-with-backup-success-messages-bloating-your-error-logs/ |
| 218 | +-- https://www.sqlskills.com/blogs/paul/fed-up-with-backup-success-messages-bloating-your-error-logs/ |
216 | 219 |
|
217 | 220 | -- TF 6533 - Spatial performance improvements in SQL Server 2012 and 2014 |
218 | 221 | -- https://support.microsoft.com/en-us/kb/3107399 |
@@ -276,7 +279,7 @@ ORDER BY sj.name OPTION (RECOMPILE); |
276 | 279 | -- Look for jobs that have a notify_level_email set to 0 (meaning no e-mail is ever sent) |
277 | 280 | -- |
278 | 281 | -- MSDN sysjobs documentation |
279 | | --- http://msdn.microsoft.com/en-us/library/ms189817.aspx |
| 282 | +-- https://msdn.microsoft.com/en-us/library/ms189817.aspx |
280 | 283 |
|
281 | 284 | -- SQL Server Maintenance Solution |
282 | 285 | -- https://ola.hallengren.com/ |
@@ -327,7 +330,7 @@ FROM sys.dm_os_windows_info WITH (NOLOCK) OPTION (RECOMPILE); |
327 | 330 |
|
328 | 331 | -- SQL Server NUMA Node information (Query 11) (SQL Server NUMA Info) |
329 | 332 | SELECT node_id, node_state_desc, memory_node_id, processor_group, online_scheduler_count, |
330 | | - active_worker_count, avg_load_balance, resource_monitor_state |
| 333 | + idle_scheduler_count, active_worker_count, avg_load_balance, resource_monitor_state |
331 | 334 | FROM sys.dm_os_nodes WITH (NOLOCK) |
332 | 335 | WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); |
333 | 336 | ------ |
@@ -362,7 +365,6 @@ FROM sys.dm_os_sys_memory WITH (NOLOCK) OPTION (RECOMPILE); |
362 | 365 | -- Physical memory state is transitioning |
363 | 366 |
|
364 | 367 |
|
365 | | - |
366 | 368 | -- You can skip the next two queries if you know you don't have a clustered instance |
367 | 369 |
|
368 | 370 |
|
@@ -423,7 +425,6 @@ EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\Syste |
423 | 425 | -- Not as useful for virtualization |
424 | 426 |
|
425 | 427 |
|
426 | | - |
427 | 428 | -- Get processor description from Windows Registry (Query 18) (Processor Description) |
428 | 429 | EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\CentralProcessor\0', N'ProcessorNameString'; |
429 | 430 | ------ |
@@ -551,7 +552,9 @@ ORDER BY [Overall Latency] OPTION (RECOMPILE); |
551 | 552 | ------ |
552 | 553 |
|
553 | 554 | -- Shows you the drive-level latency for reads and writes, in milliseconds |
554 | | --- Latency above 20-25ms is usually a problem |
| 555 | +-- Latency above 30-40ms is usually a problem |
| 556 | +-- These latency numbers include all file activity against all SQL Server |
| 557 | +-- database files on each drive since SQL Server was last started |
555 | 558 |
|
556 | 559 |
|
557 | 560 | -- Calculates average stalls per read, per write, and per total input/output for each database file (Query 24) (IO Stalls by File) |
@@ -614,12 +617,10 @@ SELECT db.[name] AS [Database Name], SUSER_SNAME(db.owner_sid) AS [Database Owne |
614 | 617 | db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], |
615 | 618 | CONVERT(DECIMAL(18,2), ls.cntr_value/1024.0) AS [Log Size (MB)], CONVERT(DECIMAL(18,2), lu.cntr_value/1024.0) AS [Log Used (MB)], |
616 | 619 | CAST(CAST(lu.cntr_value AS FLOAT) / CAST(ls.cntr_value AS FLOAT)AS DECIMAL(18,2)) * 100 AS [Log Used %], |
617 | | -db.[compatibility_level] AS [DB Compatibility Level], |
618 | | -db.page_verify_option_desc AS [Page Verify Option], db.is_auto_create_stats_on, db.is_auto_update_stats_on, |
619 | | -db.is_auto_update_stats_async_on, db.is_parameterization_forced, |
620 | | -db.snapshot_isolation_state_desc, db.is_read_committed_snapshot_on, |
621 | | -db.is_auto_close_on, db.is_auto_shrink_on, db.target_recovery_time_in_seconds, db.is_cdc_enabled, |
622 | | -db.is_published, db.group_database_id, db.replica_id, |
| 620 | +db.[compatibility_level] AS [DB Compatibility Level], db.page_verify_option_desc AS [Page Verify Option], |
| 621 | +db.is_auto_create_stats_on, db.is_auto_update_stats_on, db.is_auto_update_stats_async_on, db.is_parameterization_forced, |
| 622 | +db.snapshot_isolation_state_desc, db.is_read_committed_snapshot_on, db.is_auto_close_on, db.is_auto_shrink_on, |
| 623 | +db.target_recovery_time_in_seconds, db.is_cdc_enabled, db.is_published, db.group_database_id, db.replica_id, |
623 | 624 | db.is_encrypted, de.encryption_state, de.percent_complete, de.key_algorithm, de.key_length |
624 | 625 | FROM sys.databases AS db WITH (NOLOCK) |
625 | 626 | INNER JOIN sys.dm_os_performance_counters AS lu WITH (NOLOCK) |
@@ -898,7 +899,6 @@ ON t1.lock_owner_address = t2.resource_address OPTION (RECOMPILE); |
898 | 899 |
|
899 | 900 |
|
900 | 901 | -- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 36) (CPU Utilization History) |
901 | | --- This version works with SQL Server 2012 |
902 | 902 | DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks) FROM sys.dm_os_sys_info WITH (NOLOCK)); |
903 | 903 |
|
904 | 904 | SELECT TOP(256) SQLProcessUtilization AS [SQL Server Process CPU Utilization], |
@@ -989,6 +989,7 @@ ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE); |
989 | 989 | -- These are cached SQL statements or batches that aren't in stored procedures, functions and triggers |
990 | 990 | -- Watch out for high values for CACHESTORE_SQLCP |
991 | 991 | -- Enabling 'optimize for ad hoc workloads' at the instance level can help reduce this |
| 992 | +-- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this |
992 | 993 |
|
993 | 994 | -- CACHESTORE_OBJCP Object Plans |
994 | 995 | -- These are compiled plans for stored procedures, functions and triggers |
@@ -1074,8 +1075,7 @@ SELECT f.name AS [File Name] , f.physical_name AS [Physical Name], |
1074 | 1075 | CAST((f.size/128.0) AS DECIMAL(15,2)) AS [Total Size in MB], |
1075 | 1076 | CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) |
1076 | 1077 | AS [Available Space In MB], f.[file_id], fg.name AS [Filegroup Name], |
1077 | | -f.is_percent_growth, f.growth, |
1078 | | -fg.is_default, fg.is_read_only |
| 1078 | +f.is_percent_growth, f.growth, fg.is_default, fg.is_read_only |
1079 | 1079 | FROM sys.database_files AS f WITH (NOLOCK) |
1080 | 1080 | LEFT OUTER JOIN sys.filegroups AS fg WITH (NOLOCK) |
1081 | 1081 | ON f.data_space_id = fg.data_space_id |
@@ -1127,7 +1127,7 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE); |
1127 | 1127 | ------ |
1128 | 1128 |
|
1129 | 1129 |
|
1130 | | --- Queries 47 through 52 are the "Bad Man List" |
| 1130 | +-- Queries 47 through 52 are the "Bad Man List" for stored procedures |
1131 | 1131 | -- Top Cached SPs By Execution Count (Query 47) (SP Execution Counts) |
1132 | 1132 | SELECT TOP(100) p.name AS [SP Name], qs.execution_count, |
1133 | 1133 | ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], |
@@ -1548,3 +1548,7 @@ ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); |
1548 | 1548 |
|
1549 | 1549 | -- Microsoft IT Pro Cloud Essentials |
1550 | 1550 | -- http://bit.ly/2443SAd |
| 1551 | + |
| 1552 | + |
| 1553 | +-- August 2017 blog series about upgrading and migrating SQL Server |
| 1554 | +-- https://www.sqlskills.com/blogs/glenn/category/upgrading-sql-server/ |
0 commit comments