{"id":4421,"date":"2014-11-12T12:19:32","date_gmt":"2014-11-12T20:19:32","guid":{"rendered":"http:\/\/3.209.169.194\/blogs\/paul\/?p=4421"},"modified":"2026-11-04T19:35:12","modified_gmt":"2026-11-05T03:35:12","slug":"capturing-wait-statistics-period-time","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/","title":{"rendered":"Capturing wait statistics for a period of time"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"4421\" class=\"elementor elementor-4421\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-26e2abde elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"26e2abde\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-571a87a8\" data-id=\"571a87a8\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-cf74f0e elementor-widget elementor-widget-text-editor\" data-id=\"cf74f0e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>(Edit Check out my comprehensive library of all wait types and latch classes &#8211; see <a href=\"https:\/\/www.SQLskills.com\/help\/waits\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.)<\/p><p>(Last updated November 4, 2026)<\/p><p>In both my wait statistics pre-conference workshops at the PASS Summit and SQLintersection I promised to do a bunch of blog posts. The first one on the list is a simple script to allow you to capture all the waits that occurred over a period of time.<\/p><p>The script does the following:<\/p><ul><li>Creates two temporary tables<\/li><li>Captures the output from sys.dm_os_wait_stats into the first table<\/li><li>Waits for a configurable delay (line 41 in the script &#8211; I made it 30 minutes in the example)<\/li><li>Captures the output from sys.dm_os_wait_stats into the second\u00a0table<\/li><li>Provides my usual wait stats output on the results<\/li><\/ul><p>Enjoy!<\/p><pre>\n\/*============================================================================\nFile: ShortPeriodWaitStats.sql\n\nSummary: Short snapshot of wait stats\n\nSQL Server Versions: 2005 onwards\n------------------------------------------------------------------------------\nWritten by Paul S. Randal, SQLskills.com\n\n(c) 2018, SQLskills.com. All rights reserved.\n\nLast update 11\/4\/2026\n\nFor more scripts and sample code, check out http:\/\/www.SQLskills.com\n\nYou may alter this code for your own *non-commercial* purposes (e.g. in a\nfor-sale commercial tool). Use in your own environment is encouraged.\nYou may republish altered code as long as you include this copyright and\ngive due credit, but you must obtain prior permission before blogging\nthis code.\n\nTHIS CODE AND INFORMATION ARE PROVIDED \"AS IS\" WITHOUT WARRANTY OF\nANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED\nTO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\/OR FITNESS FOR A\nPARTICULAR PURPOSE.\n============================================================================*\/\n\nIF EXISTS (SELECT * FROM [tempdb].[sys].[objects]\nWHERE [name] = N'##SQLskillsStats1')\nDROP TABLE [##SQLskillsStats1];\n\nIF EXISTS (SELECT * FROM [tempdb].[sys].[objects]\nWHERE [name] = N'##SQLskillsStats2')\nDROP TABLE [##SQLskillsStats2];\nGO\n\nSELECT [wait_type], [waiting_tasks_count], [wait_time_ms],\n[max_wait_time_ms], [signal_wait_time_ms]\nINTO ##SQLskillsStats1\nFROM sys.dm_os_wait_stats;\nGO\n\nWAITFOR DELAY '00:30:00';\nGO\n\nSELECT [wait_type], [waiting_tasks_count], [wait_time_ms],\n[max_wait_time_ms], [signal_wait_time_ms]\nINTO ##SQLskillsStats2\nFROM sys.dm_os_wait_stats;\nGO\n\nWITH [DiffWaits] AS\n(SELECT\n\t-- Waits that weren't in the first snapshot\n\t[ts2].[wait_type],\n\t[ts2].[wait_time_ms],\n\t[ts2].[signal_wait_time_ms],\n\t[ts2].[waiting_tasks_count]\nFROM [##SQLskillsStats2] AS [ts2]\nLEFT OUTER JOIN [##SQLskillsStats1] AS [ts1]\n\tON [ts2].[wait_type] = [ts1].[wait_type]\nWHERE [ts1].[wait_type] IS NULL\n\tAND [ts2].[wait_time_ms] &gt; 0\nUNION\nSELECT\n\t-- Diff of waits in both snapshots\n\t[ts2].[wait_type],\n\t[ts2].[wait_time_ms] - [ts1].[wait_time_ms] AS [wait_time_ms],\n\t[ts2].[signal_wait_time_ms] - [ts1].[signal_wait_time_ms] AS [signal_wait_time_ms],\n\t[ts2].[waiting_tasks_count] - [ts1].[waiting_tasks_count] AS [waiting_tasks_count]\nFROM [##SQLskillsStats2] AS [ts2]\nLEFT OUTER JOIN [##SQLskillsStats1] AS [ts1]\n\tON [ts2].[wait_type] = [ts1].[wait_type]\nWHERE [ts1].[wait_type] IS NOT NULL\n\tAND [ts2].[waiting_tasks_count] - [ts1].[waiting_tasks_count] &gt; 0\n\tAND [ts2].[wait_time_ms] - [ts1].[wait_time_ms] &gt; 0),\n[Waits] AS\n\t(SELECT\n\t\t[wait_type],\n\t\t[wait_time_ms] \/ 1000.0 AS [WaitS],\n\t\t([wait_time_ms] - [signal_wait_time_ms]) \/ 1000.0 AS [ResourceS],\n\t\t[signal_wait_time_ms] \/ 1000.0 AS [SignalS],\n\t\t[waiting_tasks_count] AS [WaitCount],\n\t\t100.0 * [wait_time_ms] \/ SUM ([wait_time_ms]) OVER() AS [Percentage],\n\t\tROW_NUMBER() OVER(ORDER BY [wait_time_ms] DESC) AS [RowNum]\n\tFROM [DiffWaits]\n\tWHERE [wait_type] NOT IN (\n\t\t-- These wait types are almost 100% never a problem and so they are\n\t\t-- filtered out to avoid them skewing the results. Click on the URL\n\t\t-- for more information.\n\t\tN'BROKER_EVENTHANDLER', -- https:\/\/www.sqlskills.com\/help\/waits\/BROKER_EVENTHANDLER\n\t\tN'BROKER_RECEIVE_WAITFOR', -- https:\/\/www.sqlskills.com\/help\/waits\/BROKER_RECEIVE_WAITFOR\n\t\tN'BROKER_TASK_STOP', -- https:\/\/www.sqlskills.com\/help\/waits\/BROKER_TASK_STOP\n\t\tN'BROKER_TO_FLUSH', -- https:\/\/www.sqlskills.com\/help\/waits\/BROKER_TO_FLUSH\n\t\tN'BROKER_TRANSMITTER', -- https:\/\/www.sqlskills.com\/help\/waits\/BROKER_TRANSMITTER\n\t\tN'CHECKPOINT_QUEUE', -- https:\/\/www.sqlskills.com\/help\/waits\/CHECKPOINT_QUEUE\n\t\tN'CHKPT', -- https:\/\/www.sqlskills.com\/help\/waits\/CHKPT\n\t\tN'CLR_AUTO_EVENT', -- https:\/\/www.sqlskills.com\/help\/waits\/CLR_AUTO_EVENT\n\t\tN'CLR_MANUAL_EVENT', -- https:\/\/www.sqlskills.com\/help\/waits\/CLR_MANUAL_EVENT\n\t\tN'CLR_SEMAPHORE', -- https:\/\/www.sqlskills.com\/help\/waits\/CLR_SEMAPHORE\n\n\t\t-- Maybe comment this out if having parallelism issues\n\t\tN'CXCONSUMER', -- https:\/\/www.sqlskills.com\/help\/waits\/CXCONSUMER\n\n\t\t-- Maybe comment these four out if you have mirroring issues\n\t\tN'DBMIRROR_DBM_EVENT', -- https:\/\/www.sqlskills.com\/help\/waits\/DBMIRROR_DBM_EVENT\n\t\tN'DBMIRROR_EVENTS_QUEUE', -- https:\/\/www.sqlskills.com\/help\/waits\/DBMIRROR_EVENTS_QUEUE\n\t\tN'DBMIRROR_WORKER_QUEUE', -- https:\/\/www.sqlskills.com\/help\/waits\/DBMIRROR_WORKER_QUEUE\n\t\tN'DBMIRRORING_CMD', -- https:\/\/www.sqlskills.com\/help\/waits\/DBMIRRORING_CMD\n\n\t\tN'DIRTY_PAGE_POLL', -- https:\/\/www.sqlskills.com\/help\/waits\/DIRTY_PAGE_POLL\n\t\tN'DISPATCHER_QUEUE_SEMAPHORE', -- https:\/\/www.sqlskills.com\/help\/waits\/DISPATCHER_QUEUE_SEMAPHORE\n\t\tN'EXECSYNC', -- https:\/\/www.sqlskills.com\/help\/waits\/EXECSYNC\n\t\tN'FSAGENT', -- https:\/\/www.sqlskills.com\/help\/waits\/FSAGENT\n\t\tN'FT_IFTS_SCHEDULER_IDLE_WAIT', -- https:\/\/www.sqlskills.com\/help\/waits\/FT_IFTS_SCHEDULER_IDLE_WAIT\n\t\tN'FT_IFTSHC_MUTEX', -- https:\/\/www.sqlskills.com\/help\/waits\/FT_IFTSHC_MUTEX\n\n\t\t-- Maybe comment these six out if you have AG issues\n\t\tN'HADR_CLUSAPI_CALL', -- https:\/\/www.sqlskills.com\/help\/waits\/HADR_CLUSAPI_CALL\n\t\tN'HADR_FILESTREAM_IOMGR_IOCOMPLETION', -- https:\/\/www.sqlskills.com\/help\/waits\/HADR_FILESTREAM_IOMGR_IOCOMPLETION\n\t\tN'HADR_LOGCAPTURE_WAIT', -- https:\/\/www.sqlskills.com\/help\/waits\/HADR_LOGCAPTURE_WAIT\n\t\tN'HADR_NOTIFICATION_DEQUEUE', -- https:\/\/www.sqlskills.com\/help\/waits\/HADR_NOTIFICATION_DEQUEUE\n\t\tN'HADR_TIMER_TASK', -- https:\/\/www.sqlskills.com\/help\/waits\/HADR_TIMER_TASK\n\t\tN'HADR_WORK_QUEUE', -- https:\/\/www.sqlskills.com\/help\/waits\/HADR_WORK_QUEUE\n\n\t\tN'KSOURCE_WAKEUP', -- https:\/\/www.sqlskills.com\/help\/waits\/KSOURCE_WAKEUP\n\t\t--N'LAZYWRITER_SLEEP', -- https:\/\/www.sqlskills.com\/help\/waits\/LAZYWRITER_SLEEP\n\t\tN'LOGMGR_QUEUE', -- https:\/\/www.sqlskills.com\/help\/waits\/LOGMGR_QUEUE\n\t\tN'MEMORY_ALLOCATION_EXT', -- https:\/\/www.sqlskills.com\/help\/waits\/MEMORY_ALLOCATION_EXT\n\t\tN'ONDEMAND_TASK_QUEUE', -- https:\/\/www.sqlskills.com\/help\/waits\/ONDEMAND_TASK_QUEUE\n\t\tN'PARALLEL_REDO_DRAIN_WORKER', -- https:\/\/www.sqlskills.com\/help\/waits\/PARALLEL_REDO_DRAIN_WORKER\n\t\tN'PARALLEL_REDO_LOG_CACHE', -- https:\/\/www.sqlskills.com\/help\/waits\/PARALLEL_REDO_LOG_CACHE\n\t\tN'PARALLEL_REDO_TRAN_LIST', -- https:\/\/www.sqlskills.com\/help\/waits\/PARALLEL_REDO_TRAN_LIST\n\t\tN'PARALLEL_REDO_WORKER_SYNC', -- https:\/\/www.sqlskills.com\/help\/waits\/PARALLEL_REDO_WORKER_SYNC\n\t\tN'PARALLEL_REDO_WORKER_WAIT_WORK', -- https:\/\/www.sqlskills.com\/help\/waits\/PARALLEL_REDO_WORKER_WAIT_WORK\n\t\tN'PREEMPTIVE_OS_FLUSHFILEBUFFERS', -- https:\/\/www.sqlskills.com\/help\/waits\/PREEMPTIVE_OS_FLUSHFILEBUFFERS\n\t\t--N'PREEMPTIVE_XE_DISPATCHER', -- https:\/\/www.sqlskills.com\/help\/waits\/PREEMPTIVE_XE_DISPATCHER\n\t\tN'PREEMPTIVE_XE_GETTARGETSTATE', -- https:\/\/www.sqlskills.com\/help\/waits\/PREEMPTIVE_XE_GETTARGETSTATE\n\t\tN'PWAIT_ALL_COMPONENTS_INITIALIZED', -- https:\/\/www.sqlskills.com\/help\/waits\/PWAIT_ALL_COMPONENTS_INITIALIZED\n\t\tN'PWAIT_DIRECTLOGCONSUMER_GETNEXT', -- https:\/\/www.sqlskills.com\/help\/waits\/PWAIT_DIRECTLOGCONSUMER_GETNEXT\n\t\tN'PWAIT_EXTENSIBILITY_CLEANUP_TASK', -- https:\/\/www.sqlskills.com\/help\/waits\/PWAIT_EXTENSIBILITY_CLEANUP_TASK\n\t\tN'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', -- https:\/\/www.sqlskills.com\/help\/waits\/QDS_PERSIST_TASK_MAIN_LOOP_SLEEP\n\t\tN'QDS_ASYNC_QUEUE', -- https:\/\/www.sqlskills.com\/help\/waits\/QDS_ASYNC_QUEUE\n\t\tN'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP',\n\t\t    -- https:\/\/www.sqlskills.com\/help\/waits\/QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP\n\t\tN'QDS_SHUTDOWN_QUEUE', -- https:\/\/www.sqlskills.com\/help\/waits\/QDS_SHUTDOWN_QUEUE\n\t\tN'REDO_THREAD_PENDING_WORK', -- https:\/\/www.sqlskills.com\/help\/waits\/REDO_THREAD_PENDING_WORK\n\t\tN'REQUEST_FOR_DEADLOCK_SEARCH', -- https:\/\/www.sqlskills.com\/help\/waits\/REQUEST_FOR_DEADLOCK_SEARCH\n\t\tN'RESOURCE_QUEUE', -- https:\/\/www.sqlskills.com\/help\/waits\/RESOURCE_QUEUE\n\t\tN'SERVER_IDLE_CHECK', -- https:\/\/www.sqlskills.com\/help\/waits\/SERVER_IDLE_CHECK\n\t\tN'SLEEP_BPOOL_FLUSH', -- https:\/\/www.sqlskills.com\/help\/waits\/SLEEP_BPOOL_FLUSH\n\t\tN'SLEEP_DBSTARTUP', -- https:\/\/www.sqlskills.com\/help\/waits\/SLEEP_DBSTARTUP\n\t\tN'SLEEP_DCOMSTARTUP', -- https:\/\/www.sqlskills.com\/help\/waits\/SLEEP_DCOMSTARTUP\n\t\tN'SLEEP_MASTERDBREADY', -- https:\/\/www.sqlskills.com\/help\/waits\/SLEEP_MASTERDBREADY\n\t\tN'SLEEP_MASTERMDREADY', -- https:\/\/www.sqlskills.com\/help\/waits\/SLEEP_MASTERMDREADY\n\t\tN'SLEEP_MASTERUPGRADED', -- https:\/\/www.sqlskills.com\/help\/waits\/SLEEP_MASTERUPGRADED\n\t\tN'SLEEP_MSDBSTARTUP', -- https:\/\/www.sqlskills.com\/help\/waits\/SLEEP_MSDBSTARTUP\n\t\tN'SLEEP_SYSTEMTASK', -- https:\/\/www.sqlskills.com\/help\/waits\/SLEEP_SYSTEMTASK\n\t\tN'SLEEP_TASK', -- https:\/\/www.sqlskills.com\/help\/waits\/SLEEP_TASK\n\t\tN'SLEEP_TEMPDBSTARTUP', -- https:\/\/www.sqlskills.com\/help\/waits\/SLEEP_TEMPDBSTARTUP\n\t\tN'SNI_HTTP_ACCEPT', -- https:\/\/www.sqlskills.com\/help\/waits\/SNI_HTTP_ACCEPT\n\t\tN'SOS_WORK_DISPATCHER', -- https:\/\/www.sqlskills.com\/help\/waits\/SOS_WORK_DISPATCHER\n\t\tN'SP_SERVER_DIAGNOSTICS_SLEEP', -- https:\/\/www.sqlskills.com\/help\/waits\/SP_SERVER_DIAGNOSTICS_SLEEP\n\t\tN'SQLTRACE_BUFFER_FLUSH', -- https:\/\/www.sqlskills.com\/help\/waits\/SQLTRACE_BUFFER_FLUSH\n\t\tN'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', -- https:\/\/www.sqlskills.com\/help\/waits\/SQLTRACE_INCREMENTAL_FLUSH_SLEEP\n\t\tN'SQLTRACE_WAIT_ENTRIES', -- https:\/\/www.sqlskills.com\/help\/waits\/SQLTRACE_WAIT_ENTRIES\n        N'VDI_CLIENT_OTHER', -- https:\/\/www.sqlskills.com\/help\/waits\/VDI_CLIENT_OTHER\n\t\tN'WAIT_FOR_RESULTS', -- https:\/\/www.sqlskills.com\/help\/waits\/WAIT_FOR_RESULTS\n\t\tN'WAITFOR', -- https:\/\/www.sqlskills.com\/help\/waits\/WAITFOR\n\t\tN'WAITFOR_TASKSHUTDOWN', -- https:\/\/www.sqlskills.com\/help\/waits\/WAITFOR_TASKSHUTDOWN\n\t\tN'WAIT_XTP_RECOVERY', -- https:\/\/www.sqlskills.com\/help\/waits\/WAIT_XTP_RECOVERY\n\t\tN'WAIT_XTP_HOST_WAIT', -- https:\/\/www.sqlskills.com\/help\/waits\/WAIT_XTP_HOST_WAIT\n\t\tN'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', -- https:\/\/www.sqlskills.com\/help\/waits\/WAIT_XTP_OFFLINE_CKPT_NEW_LOG\n\t\tN'WAIT_XTP_CKPT_CLOSE', -- https:\/\/www.sqlskills.com\/help\/waits\/WAIT_XTP_CKPT_CLOSE\n\t\tN'XE_DISPATCHER_JOIN', -- https:\/\/www.sqlskills.com\/help\/waits\/XE_DISPATCHER_JOIN\n\t\tN'XE_DISPATCHER_WAIT', -- https:\/\/www.sqlskills.com\/help\/waits\/XE_DISPATCHER_WAIT\n\t\tN'XE_TIMER_EVENT' -- https:\/\/www.sqlskills.com\/help\/waits\/XE_TIMER_EVENT\n\t))\nSELECT\n\t[W1].[wait_type] AS [WaitType],\n\tCAST ([W1].[WaitS] AS DECIMAL (16, 2)) AS [Wait_S],\n\tCAST ([W1].[ResourceS] AS DECIMAL (16, 2)) AS [Resource_S],\n\tCAST ([W1].[SignalS] AS DECIMAL (16, 2)) AS [Signal_S],\n\t[W1].[WaitCount] AS [WaitCount],\n\tCAST ([W1].[Percentage] AS DECIMAL (5, 2)) AS [Percentage],\n\tCAST (([W1].[WaitS] \/ [W1].[WaitCount]) AS DECIMAL (16, 4)) AS [AvgWait_S],\n\tCAST (([W1].[ResourceS] \/ [W1].[WaitCount]) AS DECIMAL (16, 4)) AS [AvgRes_S],\n\tCAST (([W1].[SignalS] \/ [W1].[WaitCount]) AS DECIMAL (16, 4)) AS [AvgSig_S],\n\tCAST ('https:\/\/www.sqlskills.com\/help\/waits\/' + MAX ([W1].[wait_type]) as XML) AS [Help\/Info URL]\nFROM [Waits] AS [W1]\nINNER JOIN [Waits] AS [W2]\n\tON [W2].[RowNum] &lt;= [W1].[RowNum]\nGROUP BY [W1].[RowNum], [W1].[wait_type], [W1].[WaitS],\n\t[W1].[ResourceS], [W1].[SignalS], [W1].[WaitCount], [W1].[Percentage]\nHAVING SUM ([W2].[Percentage]) - [W1].[Percentage] &lt; 95; -- percentage threshold\nGO\n\n-- Cleanup\nIF EXISTS (SELECT * FROM [tempdb].[sys].[objects]\nWHERE [name] = N'##SQLskillsStats1')\nDROP TABLE [##SQLskillsStats1];\n\nIF EXISTS (SELECT * FROM [tempdb].[sys].[objects]\nWHERE [name] = N'##SQLskillsStats2')\nDROP TABLE [##SQLskillsStats2];\nGO\n<\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>(Edit Check out my comprehensive library of all wait types and latch classes &#8211; see here.) (Last updated November 4, 2026) In both my wait statistics pre-conference workshops at the PASS Summit and SQLintersection I promised to do a bunch of blog posts. The first one on the list is a simple script to allow [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,66,101],"tags":[],"class_list":["post-4421","post","type-post","status-publish","format-standard","hentry","category-example-scripts","category-performance-tuning","category-wait-stats"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Capturing wait statistics for a period of time - Paul S. Randal<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Capturing wait statistics for a period of time - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"(Edit Check out my comprehensive library of all wait types and latch classes &#8211; see here.) (Last updated November 4, 2026) In both my wait statistics pre-conference workshops at the PASS Summit and SQLintersection I promised to do a bunch of blog posts. The first one on the list is a simple script to allow [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2014-11-12T20:19:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-05T03:35:12+00:00\" \/>\n<meta name=\"author\" content=\"Paul Randal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Randal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/capturing-wait-statistics-period-time\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/capturing-wait-statistics-period-time\\\/\"},\"author\":{\"name\":\"Paul Randal\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/#\\\/schema\\\/person\\\/ffcec826c18782e1e0adf173826a7fce\"},\"headline\":\"Capturing wait statistics for a period of time\",\"datePublished\":\"2014-11-12T20:19:32+00:00\",\"dateModified\":\"2026-11-05T03:35:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/capturing-wait-statistics-period-time\\\/\"},\"wordCount\":136,\"commentCount\":16,\"articleSection\":[\"Example Scripts\",\"Performance Tuning\",\"Wait Stats\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/capturing-wait-statistics-period-time\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/capturing-wait-statistics-period-time\\\/\",\"url\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/capturing-wait-statistics-period-time\\\/\",\"name\":\"Capturing wait statistics for a period of time - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/#website\"},\"datePublished\":\"2014-11-12T20:19:32+00:00\",\"dateModified\":\"2026-11-05T03:35:12+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/#\\\/schema\\\/person\\\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/capturing-wait-statistics-period-time\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/capturing-wait-statistics-period-time\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/capturing-wait-statistics-period-time\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Capturing wait statistics for a period of time\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/\",\"name\":\"Paul S. Randal\",\"description\":\"In Recovery...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/#\\\/schema\\\/person\\\/ffcec826c18782e1e0adf173826a7fce\",\"name\":\"Paul Randal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"caption\":\"Paul Randal\"},\"sameAs\":[\"http:\\\/\\\/3.209.169.194\\\/blogs\\\/paul\"],\"url\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/paul\\\/author\\\/paul\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Capturing wait statistics for a period of time - Paul S. Randal","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/","og_locale":"en_US","og_type":"article","og_title":"Capturing wait statistics for a period of time - Paul S. Randal","og_description":"(Edit Check out my comprehensive library of all wait types and latch classes &#8211; see here.) (Last updated November 4, 2026) In both my wait statistics pre-conference workshops at the PASS Summit and SQLintersection I promised to do a bunch of blog posts. The first one on the list is a simple script to allow [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/","og_site_name":"Paul S. Randal","article_published_time":"2014-11-12T20:19:32+00:00","article_modified_time":"2026-11-05T03:35:12+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/#article","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/"},"author":{"name":"Paul Randal","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"headline":"Capturing wait statistics for a period of time","datePublished":"2014-11-12T20:19:32+00:00","dateModified":"2026-11-05T03:35:12+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/"},"wordCount":136,"commentCount":16,"articleSection":["Example Scripts","Performance Tuning","Wait Stats"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/","name":"Capturing wait statistics for a period of time - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2014-11-12T20:19:32+00:00","dateModified":"2026-11-05T03:35:12+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/capturing-wait-statistics-period-time\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Capturing wait statistics for a period of time"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/","name":"Paul S. Randal","description":"In Recovery...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce","name":"Paul Randal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","caption":"Paul Randal"},"sameAs":["http:\/\/3.209.169.194\/blogs\/paul"],"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/4421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/comments?post=4421"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/4421\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=4421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=4421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=4421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}