{"id":567,"date":"2010-10-12T19:08:00","date_gmt":"2010-10-12T19:08:00","guid":{"rendered":"\/blogs\/jonathan\/post\/TSQL-Tuesday-11-Physical-IOe28099s-Done28099t-Always-Accumulate-Wait-Times.aspx"},"modified":"2017-04-13T12:13:41","modified_gmt":"2017-04-13T16:13:41","slug":"tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/","title":{"rendered":"TSQL Tuesday #11 &#8211; Physical IO\u2019s Don\u2019t Always Accumulate Wait Times"},"content":{"rendered":"<p>\nIt is time again for another TSQL Tuesday, this time hosted by my good friend and fellow MVP, Sankar Reddy(<a href=\"http:\/\/sankarreddy.com\/\">Blog<\/a>|<a href=\"https:\/\/twitter.com\/sankarreddy13\">Twitter<\/a>).&nbsp;&nbsp; This month&rsquo;s topic is <a href=\"http:\/\/sankarreddy.com\/2010\/10\/invitation-to-participate-in-t-sql-tuesday-11-misconceptions-in-sql-server\/\">Misconceptions about SQL Server<\/a>, and as Sankar points out in this months, there are so many misconceptions out there that almost anyone can blog about this topic, in fact I might even blog more than just one post on this topic since I have a few half finished blog posts that would fit into this topic.\n<\/p>\n<p>\nFor this post I am going to look at a recent misconception from the MSDN Forums, that physical reads of a data file, correlate to wait stats inside the database engine.&nbsp; The background on this is rooted in two Dynamic Management Objects inside the database engine; the Dynamic Management Function (DMF) sys.dm_io_virtual_file_stats() which returns I\/O statistics for data and log files and the Dynamic Management View (DMV) sys.dm_os_wait_stats which returns information about all the waits encountered by threads that have executed.&nbsp; These objects reflect cumulative totals for their information, generally since the server was last restarted.&nbsp; While it is possible to reset the wait statistic information by using DBCC SQLPERF (&#39;sys.dm_os_wait_stats&#39;, CLEAR), the I\/O statistics can only be cleared by restarting the server.&nbsp; When using either of these objects for analysis of a specific time, it is important to take a snapshot of the data held in them at the start of the analysis, generally by INSERTing the information contained by the object into a temporary table and then performing a differential analysis of the data against a later SELECT from the objects (more on this in a minute).\n<\/p>\n<p>\nThe misconception on the forum thread was that I\/O stalls as reflected in the sys.dm_io_virtual_file_stats() DMF, would correlate to I\/O related wait counts, and wait times in the sys.dm_os_wait_stats DMV.&nbsp; Prior to SQL Server 2008, this kind of thing would be impossible to prove without having indepth knowledge of the Database Engine code.&nbsp; However, one of the new features in SQL Server 2008, Extended Events, actually allows us to define a Event Session to take a look at this in depth, and not only disprove the misconception, but potentially explain the what and why behind it.\n<\/p>\n<p>\nTo start off lets look at the snapshot information that lead to the misconception for a simple query against AdventureWorks:\n<\/p>\n<blockquote><p>\n\t<code><span style=\"color: blue\">USE <\/span><span style=\"color: black\">[AdventureWorks]        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Clear the Buffer Cache to force reads from Disk        <br \/>\n\t<\/span><span style=\"color: blue\">DBCC <\/span><span style=\"color: black\">DROPCLEANBUFFERS        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Drop temporary tables if they exist        <br \/>\n\t<\/span><span style=\"color: blue\">IF <\/span><span style=\"color: #ff00ff\">OBJECT_ID<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;tempdb..#io_stats&#39;<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">IS <\/span><span style=\"color: gray\">NOT NULL        <br \/>\n\t<\/span><span style=\"color: blue\">DROP TABLE <\/span><span style=\"color: #434343\">#io_stats        <br \/>\n\t<\/span><span style=\"color: black\">GO        <br \/>\n\t<\/span><span style=\"color: blue\">IF <\/span><span style=\"color: #ff00ff\">OBJECT_ID<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;tempdb..#wait_stats&#39;<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">IS <\/span><span style=\"color: gray\">NOT NULL        <br \/>\n\t<\/span><span style=\"color: blue\">DROP TABLE <\/span><span style=\"color: #434343\">#wait_stats        <br \/>\n\t<\/span><span style=\"color: black\">GO        <br \/>\n\t<\/span><span style=\"color: green\">-- Create the Snapshots of the Dynamic Management Objects        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: gray\">*        <br \/>\n\t<\/span><span style=\"color: blue\">INTO <\/span><span style=\"color: #434343\">#io_stats        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">sys.dm_io_virtual_file_stats<\/span><span style=\"color: gray\">(NULL, NULL)        <br \/>\n\t<\/span><span style=\"color: black\">GO        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: gray\">*        <br \/>\n\t<\/span><span style=\"color: blue\">INTO <\/span><span style=\"color: #434343\">#wait_stats        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">sys.dm_os_wait_stats        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Turn on Statistics IO so we can see the IO ops        <br \/>\n\t<\/span><span style=\"color: blue\">SET STATISTICS <\/span><span style=\"color: black\">IO <\/span><span style=\"color: blue\">ON        <br \/>\n\t<\/span><span style=\"color: black\">GO        <br \/>\n\t<\/span><span style=\"color: green\">-- Run the Simple SELECT against AdventureWorks        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: #ff00ff\">SUM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">TotalDue<\/span><span style=\"color: gray\">), <\/span><span style=\"color: black\">SalesPersonID        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">Sales.SalesOrderHeader        <br \/>\n\t<\/span><span style=\"color: blue\">GROUP BY <\/span><span style=\"color: black\">SalesPersonID        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Turn Off Statistics IO        <br \/>\n\t<\/span><span style=\"color: blue\">SET STATISTICS <\/span><span style=\"color: black\">IO <\/span><span style=\"color: blue\">OFF        <br \/>\n\t<\/span><span style=\"color: black\">GO        <br \/>\n\t<\/span><span style=\"color: green\">-- Get the Differential Wait Statistic Information        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">wait_type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.wait_type<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">waiting_tasks_count&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.waiting_tasks_count <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.waiting_tasks_count<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">wait_time_ms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.wait_time_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.wait_time_ms<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">max_wait_time_ms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.max_wait_time_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.max_wait_time_ms<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">signal_wait_time_ms&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.signal_wait_time_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.signal_wait_time_ms        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">sys.dm_os_wait_stats <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">t1        <br \/>\n\t<\/span><span style=\"color: blue\">JOIN <\/span><span style=\"color: #434343\">#wait_stats <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">t2        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">t1.wait_type <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t2.wait_type        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">t1.wait_time_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.wait_time_ms <\/span><span style=\"color: gray\">&gt; <\/span><span style=\"color: black\">0        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Get the Differential IO Statistic Information        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">database_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: #ff00ff\">DB_NAME<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">t1.database_id<\/span><span style=\"color: gray\">),        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">logical_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">mf.name<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">physical_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">mf.physical_name<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">num_of_reads&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.num_of_reads <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_reads<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">num_of_bytes_read&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.num_of_bytes_read <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_bytes_read<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">io_stall_read_ms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.io_stall_read_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.io_stall_read_ms<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">num_of_writes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.num_of_writes <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_writes<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">num_of_bytes_written&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.num_of_bytes_written <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_bytes_written<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">io_stall_write_ms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.io_stall_write_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.io_stall_write_ms<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">io_stall&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.io_stall <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.io_stall<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">size_on_disk_bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.size_on_disk_bytes<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">file_handle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.file_handle        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">sys.dm_io_virtual_file_stats<\/span><span style=\"color: gray\">(NULL, NULL) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">t1        <br \/>\n\t<\/span><span style=\"color: blue\">JOIN <\/span><span style=\"color: #434343\">#io_stats <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">t2        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">t1.database_id <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t2.database_id        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">t1.<\/span><span style=\"color: #ff00ff\">FILE_ID <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t2.<\/span><span style=\"color: #ff00ff\">FILE_ID        <br \/>\n\t<\/span><span style=\"color: blue\">JOIN <\/span><span style=\"color: black\">sys.master_files <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">mf        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">mf.database_id <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.database_id        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">mf.<\/span><span style=\"color: #ff00ff\">FILE_ID <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.<\/span><span style=\"color: #ff00ff\">FILE_ID        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">t1.num_of_reads <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_reads <\/span><span style=\"color: gray\">&gt; <\/span><span style=\"color: black\">0<\/span><span style=\"color: gray\">)        <br \/>\n\t&nbsp; OR (<\/span><span style=\"color: black\">t1.num_of_writes <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_writes <\/span><span style=\"color: gray\">&gt; <\/span><span style=\"color: black\">0<\/span><span style=\"color: gray\">)        <br \/>\n\t<\/span><span style=\"color: black\">GO<\/span><\/code>\n<\/p><\/blockquote>\n<p>\nThe expectation in the forums thread was that the num_of_reads, and the io_stall_read_ms values from sys.dm_io_virtual_file_stats() would have an equivalent amount of waiting_tasks_count and wait_time_ms in sys.dm_os_wait_stats, but as can be seen from the below output, this is not the case.\n<\/p>\n<p>\n<a href=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/3a3b23fa\/image.png\"><img fetchpriority=\"high\" decoding=\"async\" style=\"border-width: 0px; display: inline\" src=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/26adc459\/image_thumb.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"794\" height=\"154\" \/><\/a>\n<\/p>\n<p>\nBefore I continue with this post, let me first provide some information about the hardware basis for these tests.&nbsp; The information contained in this blog post comes from my VMware Workstation SQL Server 2008 VM running on my laptop which is a a Dell Inspiron 1400 which has 4GB RAM, and a 120GB OCZ Summit SSD.&nbsp; The VM has a single vCPU and 1GB RAM allocated to it.&nbsp; Now I would be remiss in thinking that this configuration wouldn&rsquo;t raise some eyebrows, but rest assured that I have validated these findings on multiple enterprise class VM&rsquo;s as well as physical servers including a dual quad core Dell R710 with 32GB RAM and a 8 Disk DAS that I have used in other tests for blog posts in the past.&nbsp; The results have been consistent across all of my tests and the output from my laptop VM allows me to completely isolate the workload being performed in SQL to a single execution easily.\n<\/p>\n<p>\nSo why don&rsquo;t these numbers line up?&nbsp; To explain this further we can use an Extended Event Session to look at the internal workings when the example workload query is executed:\n<\/p>\n<blockquote><p>\n\t<code><span style=\"color: blue\">IF <\/span><span style=\"color: gray\">EXISTS(<\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: gray\">*        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">sys.server_event_sessions        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">name<\/span><span style=\"color: blue\">=<\/span><span style=\"color: red\">&#39;test_session&#39;<\/span><span style=\"color: gray\">)        <br \/>\n\t&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">DROP <\/span><span style=\"color: black\">EVENT SESSION [test_session] <\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">SERVER<\/span><span style=\"color: gray\">;        <br \/>\n\t<\/span><span style=\"color: blue\">CREATE <\/span><span style=\"color: black\">EVENT SESSION [test_session]        <br \/>\n\t<\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">SERVER        <br \/>\n\t<\/span><span style=\"color: blue\">ADD <\/span><span style=\"color: black\">EVENT sqlserver.file_read<\/span><span style=\"color: gray\">(        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">ACTION <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">sqlserver.database_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.session_id<\/span><span style=\"color: gray\">)),        <br \/>\n\t<\/span><span style=\"color: blue\">ADD <\/span><span style=\"color: black\">EVENT sqlserver.file_written<\/span><span style=\"color: gray\">(        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">ACTION <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">sqlserver.database_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.session_id<\/span><span style=\"color: gray\">)),        <br \/>\n\t<\/span><span style=\"color: blue\">ADD <\/span><span style=\"color: black\">EVENT sqlserver.file_read_completed<\/span><span style=\"color: gray\">(        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">ACTION <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">sqlserver.database_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.session_id<\/span><span style=\"color: gray\">)),        <br \/>\n\t<\/span><span style=\"color: blue\">ADD <\/span><span style=\"color: black\">EVENT sqlserver.file_write_completed<\/span><span style=\"color: gray\">(        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">ACTION <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">sqlserver.database_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.session_id<\/span><span style=\"color: gray\">)),        <br \/>\n\t<\/span><span style=\"color: blue\">ADD <\/span><span style=\"color: black\">EVENT sqlos.async_io_requested<\/span><span style=\"color: gray\">(        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">ACTION <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">sqlserver.database_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.session_id<\/span><span style=\"color: gray\">)),        <br \/>\n\t<\/span><span style=\"color: blue\">ADD <\/span><span style=\"color: black\">EVENT sqlos.async_io_completed<\/span><span style=\"color: gray\">(        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">ACTION <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">sqlserver.database_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.session_id<\/span><span style=\"color: gray\">)),        <br \/>\n\t<\/span><span style=\"color: blue\">ADD <\/span><span style=\"color: black\">EVENT sqlos.wait_info<\/span><span style=\"color: gray\">(        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">ACTION <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">sqlserver.database_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.session_id<\/span><span style=\"color: gray\">)),        <br \/>\n\t<\/span><span style=\"color: blue\">ADD <\/span><span style=\"color: black\">EVENT sqlserver.sql_statement_starting<\/span><span style=\"color: gray\">(        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">ACTION <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">sqlserver.database_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.plan_handle<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">sqlserver.session_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.sql_text<\/span><span style=\"color: gray\">)),        <br \/>\n\t<\/span><span style=\"color: blue\">ADD <\/span><span style=\"color: black\">EVENT sqlserver.sql_statement_completed<\/span><span style=\"color: gray\">(        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">ACTION <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">sqlserver.database_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.plan_handle<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">sqlserver.session_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">sqlserver.sql_text<\/span><span style=\"color: gray\">))        <br \/>\n\t<\/span><span style=\"color: blue\">ADD <\/span><span style=\"color: black\">TARGET package0.ring_buffer        <br \/>\n\t<\/span><span style=\"color: blue\">WITH <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">MAX_MEMORY <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">4096KB<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">EVENT_RETENTION_MODE <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">ALLOW_SINGLE_EVENT_LOSS<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">MAX_DISPATCH_LATENCY <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">5 SECONDS<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">MAX_EVENT_SIZE <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">4096KB<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">MEMORY_PARTITION_MODE <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">PER_CPU<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">TRACK_CAUSALITY <\/span><span style=\"color: blue\">= ON<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">STARTUP_STATE <\/span><span style=\"color: blue\">= OFF<\/span><span style=\"color: gray\">)<\/span><\/code>\n<\/p><\/blockquote>\n<p>\nSome items about this Event Session that should be noted:\n<\/p>\n<ol>\n<li>The Event Session uses the TRACK_CAUSALITY session option which appends a sequential GUID to each event allowing the event sequences to be followed. <\/li>\n<li>The Event Session captures the sql_statement_starting and sql_statement_completed events allowing isolation of the associated events between these two events by the attach_activity_id action, which is collected by causality tracking. <\/li>\n<li>The Event Session captures the following IO related Events:\n<ul>\n<li>async_io_requested <\/li>\n<li>async_io_completed <\/li>\n<li>file_read <\/li>\n<li>file_read_completed <\/li>\n<li>file_written <\/li>\n<li>file_write_completed <\/li>\n<li>wait_info <\/li>\n<\/ul>\n<\/li>\n<li>The database_id and session_id actions are captured for each event, and the sql_text and plan_handle actions are captured for the sql_statement_% events. <\/li>\n<li>The event data is captured to a ring_buffer target which could result in event loss on a busy system, in which case a asynchronous_file_target would be more appropriate. <\/li>\n<li>The Event Session is configured with 4MB of buffer space that is partitioned per CPU, and a MAX_DISPATCH_LATENCY of 5 seconds. <\/li>\n<li>In the situation where the Session Buffers fill up faster than they can be dispatched single events can be lost to allow collection of incoming events. <\/li>\n<\/ol>\n<p>\nTo use the Event Session to further investigate what is going on here, we can change our original workload script to start the Event Session before running the test query, and then to drop the Events from the Event Session to disable Event collection while leaving the captured Events available in the ring_buffer target:\n<\/p>\n<blockquote><p>\n\t<code><span style=\"color: blue\">USE <\/span><span style=\"color: black\">[AdventureWorks]        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Clear the Buffer Cache to force reads from Disk        <br \/>\n\t<\/span><span style=\"color: blue\">DBCC <\/span><span style=\"color: black\">DROPCLEANBUFFERS        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Drop temporary tables if they exist        <br \/>\n\t<\/span><span style=\"color: blue\">IF <\/span><span style=\"color: #ff00ff\">OBJECT_ID<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;tempdb..#io_stats&#39;<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">IS <\/span><span style=\"color: gray\">NOT NULL        <br \/>\n\t<\/span><span style=\"color: blue\">DROP TABLE <\/span><span style=\"color: #434343\">#io_stats        <br \/>\n\t<\/span><span style=\"color: black\">GO        <br \/>\n\t<\/span><span style=\"color: blue\">IF <\/span><span style=\"color: #ff00ff\">OBJECT_ID<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;tempdb..#wait_stats&#39;<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">IS <\/span><span style=\"color: gray\">NOT NULL        <br \/>\n\t<\/span><span style=\"color: blue\">DROP TABLE <\/span><span style=\"color: #434343\">#wait_stats        <br \/>\n\t<\/span><span style=\"color: black\">GO        <br \/>\n\t<\/span><span style=\"color: green\">-- Create the Snapshots of the Dynamic Management Objects        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: gray\">*        <br \/>\n\t<\/span><span style=\"color: blue\">INTO <\/span><span style=\"color: #434343\">#io_stats        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">sys.dm_io_virtual_file_stats<\/span><span style=\"color: gray\">(NULL, NULL)        <br \/>\n\t<\/span><span style=\"color: black\">GO        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: gray\">*        <br \/>\n\t<\/span><span style=\"color: blue\">INTO <\/span><span style=\"color: #434343\">#wait_stats        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">sys.dm_os_wait_stats        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Turn on Statistics IO so we can see the IO ops        <br \/>\n\t<\/span><span style=\"color: blue\">SET STATISTICS <\/span><span style=\"color: black\">IO <\/span><span style=\"color: blue\">ON        <br \/>\n\t<\/span><span style=\"color: black\">GO        <br \/>\n\t<\/span><span style=\"color: green\">-- Start the Event Session so we capture the Events caused by running the test        <br \/>\n\t<\/span><span style=\"color: blue\">ALTER <\/span><span style=\"color: black\">EVENT SESSION test_session        <br \/>\n\t<\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">SERVER        <br \/>\n\tSTATE<\/span><span style=\"color: blue\">=<\/span><span style=\"color: black\">START        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Run the Simple SELECT against AdventureWorks        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: #ff00ff\">SUM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">TotalDue<\/span><span style=\"color: gray\">), <\/span><span style=\"color: black\">SalesPersonID        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">Sales.SalesOrderHeader        <br \/>\n\t<\/span><span style=\"color: blue\">GROUP BY <\/span><span style=\"color: black\">SalesPersonID        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Disable Event collection by dropping the Events from the Event Session        <br \/>\n\t<\/span><span style=\"color: blue\">ALTER <\/span><span style=\"color: black\">EVENT SESSION test_session        <br \/>\n\t<\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">SERVER        <br \/>\n\t&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">DROP <\/span><span style=\"color: black\">EVENT sqlos.async_io_requested<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">DROP <\/span><span style=\"color: black\">EVENT sqlos.async_io_completed<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">DROP <\/span><span style=\"color: black\">EVENT sqlos.wait_info<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">DROP <\/span><span style=\"color: black\">EVENT sqlserver.file_read<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">DROP <\/span><span style=\"color: black\">EVENT sqlserver.file_written<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">DROP <\/span><span style=\"color: black\">EVENT sqlserver.file_read_completed<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">DROP <\/span><span style=\"color: black\">EVENT sqlserver.file_write_completed<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">DROP <\/span><span style=\"color: black\">EVENT sqlserver.sql_statement_starting<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">DROP <\/span><span style=\"color: black\">EVENT sqlserver.sql_statement_completed        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Turn Off Statistics IO        <br \/>\n\t<\/span><span style=\"color: blue\">SET STATISTICS <\/span><span style=\"color: black\">IO <\/span><span style=\"color: blue\">OFF        <br \/>\n\t<\/span><span style=\"color: black\">GO        <br \/>\n\t<\/span><span style=\"color: green\">-- Get the Differential Wait Statistic Information        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">wait_type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.wait_type<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">waiting_tasks_count&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.waiting_tasks_count <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.waiting_tasks_count<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">wait_time_ms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.wait_time_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.wait_time_ms<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">max_wait_time_ms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.max_wait_time_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.max_wait_time_ms<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">signal_wait_time_ms&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.signal_wait_time_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.signal_wait_time_ms        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">sys.dm_os_wait_stats <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">t1        <br \/>\n\t<\/span><span style=\"color: blue\">JOIN <\/span><span style=\"color: #434343\">#wait_stats <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">t2        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">t1.wait_type <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t2.wait_type        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">t1.wait_time_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.wait_time_ms <\/span><span style=\"color: gray\">&gt; <\/span><span style=\"color: black\">0        <br \/>\n\tGO         <br \/>\n\t<\/span><span style=\"color: green\">-- Get the Differential IO Statistic Information        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">database_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: #ff00ff\">DB_NAME<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">t1.database_id<\/span><span style=\"color: gray\">),        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">logical_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">mf.name<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">physical_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">mf.physical_name<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">num_of_reads&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.num_of_reads <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_reads<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">num_of_bytes_read&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.num_of_bytes_read <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_bytes_read<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">io_stall_read_ms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.io_stall_read_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.io_stall_read_ms<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">num_of_writes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.num_of_writes <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_writes<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">num_of_bytes_written&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.num_of_bytes_written <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_bytes_written<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">io_stall_write_ms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.io_stall_write_ms <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.io_stall_write_ms<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">io_stall&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.io_stall <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.io_stall<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">size_on_disk_bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.size_on_disk_bytes<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">file_handle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.file_handle        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">sys.dm_io_virtual_file_stats<\/span><span style=\"color: gray\">(NULL, NULL) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">t1        <br \/>\n\t<\/span><span style=\"color: blue\">JOIN <\/span><span style=\"color: #434343\">#io_stats <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">t2        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">t1.database_id <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t2.database_id        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">t1.<\/span><span style=\"color: #ff00ff\">FILE_ID <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t2.<\/span><span style=\"color: #ff00ff\">FILE_ID        <br \/>\n\t<\/span><span style=\"color: blue\">JOIN <\/span><span style=\"color: black\">sys.master_files <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">mf        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">mf.database_id <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.database_id        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">mf.<\/span><span style=\"color: #ff00ff\">FILE_ID <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">t1.<\/span><span style=\"color: #ff00ff\">FILE_ID        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">t1.num_of_reads <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_reads <\/span><span style=\"color: gray\">&gt; <\/span><span style=\"color: black\">0<\/span><span style=\"color: gray\">)        <br \/>\n\t&nbsp; OR (<\/span><span style=\"color: black\">t1.num_of_writes <\/span><span style=\"color: gray\">- <\/span><span style=\"color: black\">t2.num_of_writes <\/span><span style=\"color: gray\">&gt; <\/span><span style=\"color: black\">0<\/span><span style=\"color: gray\">)        <br \/>\n\t<\/span><span style=\"color: black\">GO<\/span><\/code>\n<\/p><\/blockquote>\n<p>\nLooking at the raw output from this second test, we can see that it has identical num_of_reads, and num_of_bytes_read as the original query (there may be a slight variance here depending on the number of tests executed, but over 10 repeated tests, 7 of the tests returned identical results, with 2 of the remaining 3 showing 14 reads with just over\n<\/p>\n<p>\n<a href=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/7e9b1539\/image.png\"><img decoding=\"async\" style=\"border-width: 0px; display: inline\" src=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/55b00030\/image_thumb.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"792\" height=\"328\" \/><\/a>\n<\/p>\n<p>\nTo perform analysis of the Events that fired while the Event Session was capturing data, we will use a PIVOT query to rotate the information captured into a common format for analysis using the following query:\n<\/p>\n<blockquote><p>\n\t<code><span style=\"color: blue\">DROP TABLE <\/span><span style=\"color: #434343\">#Results        <\/p>\n<p>\t<\/span><span style=\"color: green\">-- Extract the Event information from the Event Session        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: green\">-- Add a RowID column to provide guaranteed Event ordering for analysis        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: #434343\">IDENTITY<\/span><span style=\"color: gray\">(<\/span><span style=\"color: blue\">INT<\/span><span style=\"color: gray\">,<\/span><span style=\"color: black\">1<\/span><span style=\"color: gray\">,<\/span><span style=\"color: black\">1<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">RowID<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">table2.<\/span><span style=\"color: gray\">*        <br \/>\n\t<\/span><span style=\"color: green\">-- INSERT the immediate results into a temp table for further analysis        <br \/>\n\t<\/span><span style=\"color: blue\">INTO <\/span><span style=\"color: #434343\">#Results        <br \/>\n\t<\/span><span style=\"color: blue\">FROM        <br \/>\n\t<\/span><span style=\"color: gray\">(&nbsp; <\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: black\">XEvent.query<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;.&#39;<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">XEvent        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">FROM        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: gray\">(&nbsp;&nbsp; <\/span><span style=\"color: green\">-- Cast the target_data to XML        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: #ff00ff\">CAST<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">target_data <\/span><span style=\"color: blue\">AS XML<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">TargetData        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">sys.dm_xe_session_targets st        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">JOIN <\/span><span style=\"color: black\">sys.dm_xe_sessions s        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">ON <\/span><span style=\"color: black\">s.address <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">st.event_session_address        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">name <\/span><span style=\"color: blue\">= <\/span><span style=\"color: red\">&#39;test_session&#39;        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">target_name <\/span><span style=\"color: blue\">= <\/span><span style=\"color: red\">&#39;ring_buffer&#39;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">Data        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: green\">-- Split out the Event Nodes        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: gray\">CROSS <\/span><span style=\"color: black\">APPLY TargetData.nodes <\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;RingBufferTarget\/event&#39;<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">XEventData <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">XEvent<\/span><span style=\"color: gray\">)&nbsp;&nbsp;&nbsp; ) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">table1        <br \/>\n\t<\/span><span style=\"color: green\">-- Use a TVF CROSS APPLY to split out the final result columns for PIVOT        <br \/>\n\t<\/span><span style=\"color: gray\">CROSS <\/span><span style=\"color: black\">APPLY        <br \/>\n\t<\/span><span style=\"color: gray\">(&nbsp; <\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: gray\">*        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">FROM        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: gray\">(&nbsp;&nbsp; <\/span><span style=\"color: green\">-- Get the Event Name        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: red\">&#39;event_name&#39; <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: red\">&#39;name&#39;<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #ff00ff\">RTRIM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: #ff00ff\">LTRIM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">XEvent.value<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;(event\/@name)[1]&#39;<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">&#39;nvarchar(max)&#39;<\/span><span style=\"color: gray\">))) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">value        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">UNION <\/span><span style=\"color: gray\">ALL        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: green\">-- Get the Event Timestamp        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: red\">&#39;timestamp&#39; <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: red\">&#39;name&#39;<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #ff00ff\">RTRIM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: #ff00ff\">LTRIM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">XEvent.value<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;(event\/@timestamp)[1]&#39;<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">&#39;nvarchar(40)&#39;<\/span><span style=\"color: gray\">))) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">value        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">UNION <\/span><span style=\"color: gray\">ALL        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: green\">-- Get the Event data columns        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #ff00ff\">RTRIM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: #ff00ff\">LTRIM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">XData.value<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;@name[1]&#39;<\/span><span style=\"color: gray\">,<\/span><span style=\"color: red\">&#39;nvarchar(max)&#39;<\/span><span style=\"color: gray\">))) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: red\">&#39;name&#39;<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #ff00ff\">RTRIM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: #ff00ff\">LTRIM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: #ff00ff\">COALESCE<\/span><span style=\"color: gray\">(<\/span><span style=\"color: #ff00ff\">NULLIF<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">XData.value<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;(text)[1]&#39;<\/span><span style=\"color: gray\">,<\/span><span style=\"color: red\">&#39;nvarchar(max)&#39;<\/span><span style=\"color: gray\">), <\/span><span style=\"color: red\">&#39;&#39;<\/span><span style=\"color: gray\">),        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">XData.value<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;(value)[1]&#39;<\/span><span style=\"color: gray\">,<\/span><span style=\"color: red\">&#39;nvarchar(max)&#39;<\/span><span style=\"color: gray\">)))) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: red\">&#39;value&#39;        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">XEvent.nodes<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;event\/data&#39;<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">Data <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">XData<\/span><span style=\"color: gray\">)        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">UNION <\/span><span style=\"color: gray\">ALL        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: green\">-- Get the Event action columns        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">XData.value<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;@name[1]&#39;<\/span><span style=\"color: gray\">,<\/span><span style=\"color: red\">&#39;nvarchar(max)&#39;<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: red\">&#39;name&#39;        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: gray\">,<\/span><span style=\"color: #ff00ff\">COALESCE<\/span><span style=\"color: gray\">(<\/span><span style=\"color: #ff00ff\">NULLIF<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">XData.value<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;(text)[1]&#39;<\/span><span style=\"color: gray\">,<\/span><span style=\"color: red\">&#39;nvarchar(max)&#39;<\/span><span style=\"color: gray\">), <\/span><span style=\"color: red\">&#39;&#39;<\/span><span style=\"color: gray\">),        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">XData.value<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;(value)[1]&#39;<\/span><span style=\"color: gray\">,<\/span><span style=\"color: red\">&#39;nvarchar(max)&#39;<\/span><span style=\"color: gray\">)) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: red\">&#39;value&#39;        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: black\">XEvent.nodes<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;event\/action&#39;<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">Data <\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">XData<\/span><span style=\"color: gray\">)&nbsp;&nbsp; ) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">tab        <br \/>\n\t&nbsp;&nbsp; PIVOT         <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: gray\">(&nbsp;&nbsp; <\/span><span style=\"color: #ff00ff\">MAX<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">value<\/span><span style=\"color: gray\">)        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: green\">-- Specify columns for PIVOT Operation        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue\">FOR <\/span><span style=\"color: black\">name <\/span><span style=\"color: blue\">IN        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: gray\">(&nbsp;&nbsp; <\/span><span style=\"color: black\">[event_name]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[timestamp]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[database_id]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[session_id]<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">[file_handle]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[wait_type]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[opcode]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[duration]<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">[signal_duration]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[mode]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[file_id]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[succeeded]<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">[page_id]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[extent_id]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[sql_text]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[plan_handle]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[cpu]<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: black\">[reads]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[writes]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[state]<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">[attach_activity_id]        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: gray\">)        <br \/>\n\t&nbsp;&nbsp; ) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">pvt        <br \/>\n\t<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">table2<\/span><\/code>\n<\/p><\/blockquote>\n<p>\nWith the data PIVOT&rsquo;d into a temporary table we can do some basic analysis of what was captured by the Event Session.\n<\/p>\n<blockquote><p>\n\t<code><span style=\"color: blue\">DECLARE <\/span><span style=\"color: #434343\">@attach_id <\/span><span style=\"color: blue\">VARCHAR<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">100<\/span><span style=\"color: gray\">)        <br \/>\n\t<\/span><span style=\"color: blue\">DECLARE <\/span><span style=\"color: #434343\">@start_event_id <\/span><span style=\"color: blue\">INT        <br \/>\n\tDECLARE <\/span><span style=\"color: #434343\">@end_event_id <\/span><span style=\"color: blue\">INT        <\/p>\n<p>\t<\/span><span style=\"color: green\">-- Set the variables for the start_event_id, and attach_id        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: #434343\">@start_event_id <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">RowID<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: #434343\">@attach_id <\/span><span style=\"color: blue\">= <\/span><span style=\"color: #ff00ff\">SUBSTRING<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">attach_activity_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">1<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<\/span><span style=\"color: #ff00ff\">LEN<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">attach_activity_id<\/span><span style=\"color: gray\">)-<\/span><span style=\"color: blue\">CHARINDEX<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;-&#39;<\/span><span style=\"color: gray\">, <\/span><span style=\"color: #ff00ff\">REVERSE<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">attach_activity_id<\/span><span style=\"color: gray\">))+<\/span><span style=\"color: black\">1<\/span><span style=\"color: gray\">))        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: #434343\">#Results        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">event_name <\/span><span style=\"color: blue\">= <\/span><span style=\"color: red\">&#39;sql_statement_starting&#39;        <br \/>\n\t<\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">sql_text <\/span><span style=\"color: gray\">LIKE <\/span><span style=\"color: red\">&#39;%SELECT SUM(TotalDue)%&#39;        <\/p>\n<p>\t<\/span><span style=\"color: green\">-- Set the variable for the end_event_id        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: #434343\">@end_event_id <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">RowID        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: #434343\">#Results        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">event_name <\/span><span style=\"color: blue\">= <\/span><span style=\"color: red\">&#39;sql_statement_completed&#39;        <br \/>\n\t<\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">sql_text <\/span><span style=\"color: gray\">LIKE <\/span><span style=\"color: red\">&#39;%SELECT SUM(TotalDue)%&#39;        <\/p>\n<p>\n\t<\/span><span style=\"color: green\">-- SELECT the rows from the captured Events that are between the start and        <br \/>\n\t-- end Event with the attach_activity_id for the start Event         <br \/>\n\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">RowID<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">event_name<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">[attach_activity_id]<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">database_id<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: #ff00ff\">FILE_ID<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">file_handle<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">mode<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">wait_type<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">opcode<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">duration<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">signal_duration<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">[sql_text]<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">[plan_handle]<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">[cpu]<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">[reads]<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">[writes]<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">[state]        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: #434343\">#Results <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">r        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">attach_activity_id <\/span><span style=\"color: gray\">LIKE <\/span><span style=\"color: #434343\">@attach_id<\/span><span style=\"color: gray\">+<\/span><span style=\"color: red\">&#39;%&#39;        <br \/>\n\t&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">RowID <\/span><span style=\"color: gray\">&gt;= <\/span><span style=\"color: #434343\">@start_event_id        <br \/>\n\t&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">RowID <\/span><span style=\"color: gray\">&lt;= <\/span><span style=\"color: #434343\">@end_event_id        <br \/>\n\t<\/span><\/code>\n<\/p><\/blockquote>\n<p>\nWith this output, we can look at the order of engine events that fired, and from a quick glance it would seem that IO operations do have PAGEIOLATCH_SH waits associated with them as highlighted below:\n<\/p>\n<p>\n<a href=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/34505a94\/image.png\"><img decoding=\"async\" style=\"border-width: 0px; display: inline\" src=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/18cb5891\/image_thumb.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"644\" height=\"176\" \/><\/a>\n<\/p>\n<p>\nWhat is quickly evident is that while the wait type might get set, it has a zero duration, yet this alone is not enough information to support the analysis here, we really have to work through the events to determine what exactly might be going on here.&nbsp; One thing that immediately stands out to me is that the PAGEIOLATCH_SH waits may not have long durations associated with them, in fact the screenshots for this post show zero durations for the events, but the file_read_completed events have durations associated with them.\n<\/p>\n<p>\n<a href=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/0150a460\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; display: inline\" src=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/0c99b89d\/image_thumb.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"644\" height=\"208\" \/><\/a>\n<\/p>\n<p>\nSo in the interests of trying to better explain the output from sys.dm_io_virtual_file_stats() lets aggregate the totals for all the wait types captured in association with this statement executing, as well as aggregate the file_read_completed durations with the wait_info durations to see how they compare to the output from sys.dm_io_virtual_file_stats().\n<\/p>\n<blockquote><p>\n\t<code><span style=\"color: blue\">DECLARE <\/span><span style=\"color: #434343\">@attach_id <\/span><span style=\"color: blue\">VARCHAR<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">100<\/span><span style=\"color: gray\">)        <br \/>\n\t<\/span><span style=\"color: blue\">DECLARE <\/span><span style=\"color: #434343\">@start_event_id <\/span><span style=\"color: blue\">INT        <br \/>\n\tDECLARE <\/span><span style=\"color: #434343\">@end_event_id <\/span><span style=\"color: blue\">INT        <\/p>\n<p>\t<\/span><span style=\"color: green\">-- Set the variables for the start_event_id, end_event_id, and attach_id        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: #434343\">@start_event_id <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">RowID<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: #434343\">@attach_id <\/span><span style=\"color: blue\">= <\/span><span style=\"color: #ff00ff\">SUBSTRING<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">attach_activity_id<\/span><span style=\"color: gray\">, <\/span><span style=\"color: black\">1<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<\/span><span style=\"color: #ff00ff\">LEN<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">attach_activity_id<\/span><span style=\"color: gray\">)-<\/span><span style=\"color: blue\">CHARINDEX<\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;-&#39;<\/span><span style=\"color: gray\">, <\/span><span style=\"color: #ff00ff\">REVERSE<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">attach_activity_id<\/span><span style=\"color: gray\">))+<\/span><span style=\"color: black\">1<\/span><span style=\"color: gray\">))        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: #434343\">#Results        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">event_name <\/span><span style=\"color: blue\">= <\/span><span style=\"color: red\">&#39;sql_statement_starting&#39;        <br \/>\n\t<\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">sql_text <\/span><span style=\"color: gray\">LIKE <\/span><span style=\"color: red\">&#39;%SELECT SUM(TotalDue)%&#39;        <\/p>\n<p>\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: #434343\">@end_event_id <\/span><span style=\"color: blue\">= <\/span><span style=\"color: black\">RowID        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: #434343\">#Results        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">event_name <\/span><span style=\"color: blue\">= <\/span><span style=\"color: red\">&#39;sql_statement_completed&#39;        <br \/>\n\t<\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">sql_text <\/span><span style=\"color: gray\">LIKE <\/span><span style=\"color: red\">&#39;%SELECT SUM(TotalDue)%&#39;        <\/p>\n<p>\n\t<\/span><span style=\"color: green\">-- Aggregate the wait types associated with the Event exectuion        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: black\">wait_type<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: #ff00ff\">COUNT<\/span><span style=\"color: gray\">(*) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">waiting_task_count<\/span><span style=\"color: gray\">,        <br \/>\n\t&nbsp;&nbsp; <\/span><span style=\"color: #ff00ff\">SUM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: #ff00ff\">CAST<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">duration <\/span><span style=\"color: blue\">AS INT<\/span><span style=\"color: gray\">)) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">duration        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: #434343\">#results        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">attach_activity_id <\/span><span style=\"color: gray\">LIKE <\/span><span style=\"color: #434343\">@attach_id<\/span><span style=\"color: gray\">+<\/span><span style=\"color: red\">&#39;%&#39;        <br \/>\n\t&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">RowID <\/span><span style=\"color: gray\">&gt;= <\/span><span style=\"color: #434343\">@start_event_id        <br \/>\n\t&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">RowID <\/span><span style=\"color: gray\">&lt;= <\/span><span style=\"color: #434343\">@end_event_id        <br \/>\n\t&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">opcode <\/span><span style=\"color: blue\">= <\/span><span style=\"color: red\">&#39;end&#39;        <br \/>\n\t<\/span><span style=\"color: blue\">GROUP BY <\/span><span style=\"color: black\">wait_type        <\/p>\n<p>\t<\/span><span style=\"color: green\">-- Aggregate the IO durations with the waits for the Event execution        <br \/>\n\t<\/span><span style=\"color: blue\">SELECT <\/span><span style=\"color: #ff00ff\">SUM<\/span><span style=\"color: gray\">(<\/span><span style=\"color: #ff00ff\">CAST<\/span><span style=\"color: gray\">(<\/span><span style=\"color: black\">duration <\/span><span style=\"color: blue\">AS INT<\/span><span style=\"color: gray\">)) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">IO_and_wait_duration        <br \/>\n\t<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: #434343\">#Results <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: black\">r        <br \/>\n\t<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: black\">attach_activity_id <\/span><span style=\"color: gray\">LIKE <\/span><span style=\"color: #434343\">@attach_id<\/span><span style=\"color: gray\">+<\/span><span style=\"color: red\">&#39;%&#39;        <br \/>\n\t&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">RowID <\/span><span style=\"color: gray\">&gt;= <\/span><span style=\"color: #434343\">@start_event_id        <br \/>\n\t&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">RowID <\/span><span style=\"color: gray\">&lt;= <\/span><span style=\"color: #434343\">@end_event_id        <br \/>\n\t&nbsp; <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: black\">event_name <\/span><span style=\"color: blue\">IN <\/span><span style=\"color: gray\">(<\/span><span style=\"color: red\">&#39;file_read_completed&#39;<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">&#39;wait_info&#39;<\/span><span style=\"color: gray\">)<\/span><\/code>\n<\/p><\/blockquote>\n<p>\n<a href=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/29bf60a7\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; display: inline\" src=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/424efdf7\/image_thumb.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"347\" height=\"132\" \/><\/a>\n<\/p>\n<p>\nWhen we compare this to the original output from sys.dm_io_virtual_file_stats(), we get closer to the total io_stall_read_ms values, though we are still not precisely there.\n<\/p>\n<p>\n<a href=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/3a3b23fa\/image.png\"><img fetchpriority=\"high\" decoding=\"async\" style=\"border-width: 0px; display: inline\" src=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/26adc459\/image_thumb.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"794\" height=\"154\" \/><\/a>\n<\/p>\n<p>\nSo what accounts for the difference here?&nbsp; Well, I could speculate, but that isn&rsquo;t really the purpose of this post, and it would only feed into further misconceptions about what the correlation of the values presented here might actually be.&nbsp; What is really clear here is that the information contained in sys.dm_io_virtual_file_stats() can not be directly correlated to the output from sys.dm_os_wait_stats.&nbsp;&nbsp; As shown in this simple, ok maybe its a bit complex because Extended Events has yet to be made simple to use, there is duration associated with file read operations that is not directly attributable to any wait type, which should be expected.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is time again for another TSQL Tuesday, this time hosted by my good friend and fellow MVP, Sankar Reddy(Blog|Twitter).&nbsp;&nbsp; This month&rsquo;s topic is Misconceptions about SQL Server, and as Sankar points out in this months, there are so many misconceptions out there that almost anyone can blog about this topic, in fact I might [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,38,42],"tags":[],"class_list":["post-567","post","type-post","status-publish","format-standard","hentry","category-extended-events","category-sql-server-2008","category-tsql2sday"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>TSQL Tuesday #11 - Physical IO\u2019s Don\u2019t Always Accumulate Wait Times - Jonathan Kehayias<\/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\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TSQL Tuesday #11 - Physical IO\u2019s Don\u2019t Always Accumulate Wait Times - Jonathan Kehayias\" \/>\n<meta property=\"og:description\" content=\"It is time again for another TSQL Tuesday, this time hosted by my good friend and fellow MVP, Sankar Reddy(Blog|Twitter).&nbsp;&nbsp; This month&rsquo;s topic is Misconceptions about SQL Server, and as Sankar points out in this months, there are so many misconceptions out there that almost anyone can blog about this topic, in fact I might [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/\" \/>\n<meta property=\"og:site_name\" content=\"Jonathan Kehayias\" \/>\n<meta property=\"article:published_time\" content=\"2010-10-12T19:08:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-04-13T16:13:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/26adc459\/image_thumb.png\" \/>\n<meta name=\"author\" content=\"Jonathan Kehayias\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jonathan Kehayias\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"21 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/\"},\"author\":{\"name\":\"Jonathan Kehayias\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/#\\\/schema\\\/person\\\/01c10d94f3648654ef706d5e6305f69c\"},\"headline\":\"TSQL Tuesday #11 &#8211; Physical IO\u2019s Don\u2019t Always Accumulate Wait Times\",\"datePublished\":\"2010-10-12T19:08:00+00:00\",\"dateModified\":\"2017-04-13T16:13:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/\"},\"wordCount\":1417,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/wp-content\\\/uploads\\\/windows-live-writer\\\/tsqltuesday11\\\/26adc459\\\/image_thumb.png\",\"articleSection\":[\"Extended Events\",\"SQL Server 2008\",\"TSQL2sday\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/\",\"url\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/\",\"name\":\"TSQL Tuesday #11 - Physical IO\u2019s Don\u2019t Always Accumulate Wait Times - Jonathan Kehayias\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/wp-content\\\/uploads\\\/windows-live-writer\\\/tsqltuesday11\\\/26adc459\\\/image_thumb.png\",\"datePublished\":\"2010-10-12T19:08:00+00:00\",\"dateModified\":\"2017-04-13T16:13:41+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/#\\\/schema\\\/person\\\/01c10d94f3648654ef706d5e6305f69c\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/wp-content\\\/uploads\\\/windows-live-writer\\\/tsqltuesday11\\\/26adc459\\\/image_thumb.png\",\"contentUrl\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/wp-content\\\/uploads\\\/windows-live-writer\\\/tsqltuesday11\\\/26adc459\\\/image_thumb.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Extended Events\",\"item\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/category\\\/extended-events\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"TSQL Tuesday #11 &#8211; Physical IO\u2019s Don\u2019t Always Accumulate Wait Times\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/\",\"name\":\"Jonathan Kehayias - The Rambling DBA\",\"description\":\"The Rambling DBA\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/?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\\\/jonathan\\\/#\\\/schema\\\/person\\\/01c10d94f3648654ef706d5e6305f69c\",\"name\":\"Jonathan Kehayias\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g\",\"caption\":\"Jonathan Kehayias\"},\"sameAs\":[\"http:\\\/\\\/3.209.169.194\\\/blogs\\\/jonathan\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"TSQL Tuesday #11 - Physical IO\u2019s Don\u2019t Always Accumulate Wait Times - Jonathan Kehayias","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\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/","og_locale":"en_US","og_type":"article","og_title":"TSQL Tuesday #11 - Physical IO\u2019s Don\u2019t Always Accumulate Wait Times - Jonathan Kehayias","og_description":"It is time again for another TSQL Tuesday, this time hosted by my good friend and fellow MVP, Sankar Reddy(Blog|Twitter).&nbsp;&nbsp; This month&rsquo;s topic is Misconceptions about SQL Server, and as Sankar points out in this months, there are so many misconceptions out there that almost anyone can blog about this topic, in fact I might [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/","og_site_name":"Jonathan Kehayias","article_published_time":"2010-10-12T19:08:00+00:00","article_modified_time":"2017-04-13T16:13:41+00:00","og_image":[{"url":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/26adc459\/image_thumb.png","type":"","width":"","height":""}],"author":"Jonathan Kehayias","twitter_misc":{"Written by":"Jonathan Kehayias","Est. reading time":"21 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/#article","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/"},"author":{"name":"Jonathan Kehayias","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/#\/schema\/person\/01c10d94f3648654ef706d5e6305f69c"},"headline":"TSQL Tuesday #11 &#8211; Physical IO\u2019s Don\u2019t Always Accumulate Wait Times","datePublished":"2010-10-12T19:08:00+00:00","dateModified":"2017-04-13T16:13:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/"},"wordCount":1417,"commentCount":0,"image":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/26adc459\/image_thumb.png","articleSection":["Extended Events","SQL Server 2008","TSQL2sday"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/","url":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/","name":"TSQL Tuesday #11 - Physical IO\u2019s Don\u2019t Always Accumulate Wait Times - Jonathan Kehayias","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/26adc459\/image_thumb.png","datePublished":"2010-10-12T19:08:00+00:00","dateModified":"2017-04-13T16:13:41+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/#\/schema\/person\/01c10d94f3648654ef706d5e6305f69c"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/#primaryimage","url":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/26adc459\/image_thumb.png","contentUrl":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-content\/uploads\/windows-live-writer\/tsqltuesday11\/26adc459\/image_thumb.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/tsql-tuesday-11-physical-ios-dont-always-accumulate-wait-times\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/"},{"@type":"ListItem","position":2,"name":"Extended Events","item":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/category\/extended-events\/"},{"@type":"ListItem","position":3,"name":"TSQL Tuesday #11 &#8211; Physical IO\u2019s Don\u2019t Always Accumulate Wait Times"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/","name":"Jonathan Kehayias - The Rambling DBA","description":"The Rambling DBA","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/?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\/jonathan\/#\/schema\/person\/01c10d94f3648654ef706d5e6305f69c","name":"Jonathan Kehayias","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g","caption":"Jonathan Kehayias"},"sameAs":["http:\/\/3.209.169.194\/blogs\/jonathan"]}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/posts\/567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/comments?post=567"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/posts\/567\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/media?parent=567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/categories?post=567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/tags?post=567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}