John Sansom SQL Server DBA in the UK

SQL Server DBA Blog, with straightforward advice, quality resources and musings about SQL Server

  • Home
  • About me
  • Books
  • How to Become a SQL Server DBA
  • Popular Posts
  • SQL Server Resources
  • UK SQL Server Events

SQL Snippet: SQL Server Wait Types

Dec 29th, 2009
by John Sansom.

Here is a handy little SQL Snippet that will return information about those all important SQL Server Wait Types for your server. It uses the SQL Server Dynamic Management View (DMV) sys.dm_os_wait_stats in order to extrapolate the desired information. A column has also been added to provide details of the percentage of total wait time that a particular Wait Type is responsible for.

T-SQL Query to rank SQL Server Wait Types by highest percentage of total wait time


SELECT
wait_type,
waiting_tasks_count,
max_wait_time_ms,
resource_wait_time_ms = (wait_time_ms - signal_wait_time_ms),
PercentOfAllResourceWaitTime =
(cast((wait_time_ms - signal_wait_time_ms) as decimal(19,2)) /
(select sum((wait_time_ms - signal_wait_time_ms)) from sys.dm_os_wait_stats))
* 100
FROM sys.dm_os_wait_stats
ORDER BY PercentOfAllResourceWaitTime DESC


I hope you find this SQL Snippet useful in your administration of SQL Server. If you have any queries regarding this snippet, SQL Server Wait Types or anything to do with SQL Server whatsoever then be sure to let me know!

Further Reading

  • SQL Server Best Practice Article: Performance Tuning Wait Queues
  • More DMV Queries: Identify All Active SQL Server Sessions
  • How to identify the most costly SQL Server queries using DMV’s
← Something for the weekend: SQL Server Links (Xmas Edition)
SQL Snippet: What SQL Server Agent Jobs were running at that time? →
  • Pingback: How to identify the most costly SQL Server queries using DMV’s | John Sansom - SQL Server DBA in the UK

  • Pingback: SQL Snippet: What SQL Server Agent Jobs were running at that time? | John Sansom - SQL Server DBA in the UK

  • Pingback: SQL Snippet: Who owns that SQL Server Job? | Santech Solutions

  • Pingback: SQL Snippet: Who owns that SQL Server Job? | John Sansom - SQL Server DBA in the UK

  • Pingback: How much memory is each SQL Server database using? | John Sansom - SQL Server DBA in the UK

  • Pingback: How to identify the most costly SQL Server queries using DMV's

  • Subscribe to RSS
  • Subscribe by Email
  • Search

  • Categories

    • Administration (54)
      • Disaster Recovery (7)
      • Dynamic Management Views (DMV) (4)
      • Index Optimisation (8)
      • Memory (2)
      • Reporting Services (5)
      • SQL Server Tips (19)
      • Tools (6)
    • Performance Tuning (18)
    • Professional Development (42)
      • Blogging (3)
      • Outstanding DBA Customer Service (5)
    • Query Optimisation (4)
    • SQL Server Community (130)
      • Reviews (1)
    • SQLServerCentral Syndication (65)
    • SQLServerPedia Syndication (63)
  • Archives

    • January 2012
    • December 2011
    • November 2011
    • October 2011
    • September 2011
    • August 2011
    • July 2011
    • June 2011
    • May 2011
    • April 2011
    • March 2011
    • February 2011
    • January 2011
    • December 2010
    • November 2010
    • October 2010
    • September 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010
    • December 2009
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009

Copyright John Sansom, 2009-2011, all rights reserved.