Tuesday, January 21, 2014

Statistics IO Parser

One of the best ways to start tuning your queries is by looking at the amount of disk activity generated by your Transact-SQL statements.

The way you do this is by setting up STATISTICS IO ON at run time like this.

SET STATISTICS IO ON

The output will display the following information.



The output of the following query would look something like:

Table 'PurchaseOrderDetail'. Scan count 1, logical reads 66, physical reads 0, read-ahead reads 64, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'PurchaseOrderHeader'. Scan count 1, logical reads 44, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.


SET STATISTICS IO ON
select * from [Purchasing].[PurchaseOrderHeader] a
join [Purchasing].[PurchaseOrderDetail] b
on a.PurchaseOrderID = b.PurchaseOrderID


where OrderDate >= '2004-05-17 00:00:00.000'

This is cool but what if you want to see the Total I/O generated by the query and see the output better formatted?  Today I found this website built by Richie Rump http://statisticsioparser.com/ which formats the output of the IO Statistics.

Just enter the output you got from turning STATISTICS IO ON and click on Parse button



You will get a nice formatted output including the IO Totals


No comments:

Post a Comment