<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.sqlprof.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tags 'Performance' and 'Tuning'</title><link>http://www.sqlprof.com/search/SearchResults.aspx?o=DateDescending&amp;tag=Performance,Tuning&amp;orTags=0</link><description>Search results matching tags 'Performance' and 'Tuning'</description><dc:language>en-US</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>How to Tune a Database Using the Database Tuning Advisor (DTA)</title><link>http://www.sqlprof.com/blogs/sqlserver/archive/2008/04/05/how-to-tune-a-database-using-the-database-tuning-advisor-dta.aspx</link><pubDate>Sat, 05 Apr 2008 13:51:14 GMT</pubDate><guid isPermaLink="false">f1c11735-f88c-466b-aadf-9e672bf81be1:38</guid><dc:creator>Eric</dc:creator><description>&lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;The Database Engine Tuning Advisor (DTA) is a new tool in SQL Server 2005 that enables you to tune databases and improve the performances of your queries. DTA examines how queries are processed in the databases you specify and then it recommends how you can improve performance by suggesting the creation of indexes and statistics.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;It replaces the Index Tuning Wizard from Microsoft SQL Server 2000. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;You can use DTA to tune a database by using workload (trace files) that were previously created with the profiler or you can tune a Query directly in Management Studio. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;A workload is a set of Transact-SQL statements that execute against the database that you want to tune. The Database Engine Tuning Advisor use trace files, trace tables, or Transact-SQL scripts as workload input when tuning databases. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;In this article, we will create a few tables in the Adventureworks sample database.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;Run the following script: &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;USE&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; AdventureWorks&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; DTA_Individual&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;Individual&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; DTA_Customer&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;Customer&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; DTA_CustomerAddress &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerAddress&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; DTA_Address&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Person&lt;span style="color:gray;"&gt;.&lt;/span&gt;Address&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; DTA_Vendor&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Purchasing&lt;span style="color:gray;"&gt;.&lt;/span&gt;Vendor&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; DTA_VendorContact&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Purchasing&lt;span style="color:gray;"&gt;.&lt;/span&gt;VendorContact&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; DTA_Employee&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; HumanResources&lt;span style="color:gray;"&gt;.&lt;/span&gt;Employee&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; DTA_SalesOrderHeader&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderHeader&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; DTA_SalesOrderDetail&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderDetail&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; DTA_Product&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Production&lt;span style="color:gray;"&gt;.&lt;/span&gt;Product&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;Now we have tables to work with.&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt; &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;font size="4"&gt;Creating a Trace file: &lt;/font&gt;&lt;/span&gt;&lt;/b&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;To run SQL Server Profiler, on the &lt;span style="mso-bidi-font-weight:bold;"&gt;Start&lt;/span&gt; menu, point to &lt;span style="mso-bidi-font-weight:bold;"&gt;All Programs&lt;/span&gt;, &lt;span style="mso-bidi-font-weight:bold;"&gt;Microsoft SQL Server 2005&lt;/span&gt;, &lt;span style="mso-bidi-font-weight:bold;"&gt;Performance Tools&lt;/span&gt;, and then click &lt;span style="mso-bidi-font-weight:bold;"&gt;SQL Server Profiler&lt;/span&gt;.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;Or, you can to start the profiler from the tools menu in Management Studio.&lt;/span&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image002_4.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="185" alt="clip_image002" src="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image002_thumb_1.jpg" width="248" border="0" /&gt;&lt;/a&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt; &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Once the SQL Profiler is started, you need to create a new trace.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;“Select New Trace…” from the file menu: &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image004_4.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="128" alt="clip_image004" src="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image004_thumb_1.jpg" width="245" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;After you have connected to the server, the Trace Properties window appears: &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image006_4.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="399" alt="clip_image006" src="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image006_thumb_1.jpg" width="633" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;background:yellow;font-family:arial;mso-highlight:yellow;"&gt;The DTA assumes that the workload trace file is a rollover file.&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt; &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;The captured workload information can be stored in a file (recommended for tuning) or in a table.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;I recommend that you use the SQL Server Profiler &lt;b style="mso-bidi-font-weight:normal;"&gt;Tuning&lt;/b&gt; template for capturing workloads for DTA.&lt;/span&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;If you want to use your own template, ensure that the following trace events are captured for the version of SQL Server that you are using. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;SQL Server 2005: &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;ul style="margin-top:0cm;"&gt; &lt;li class="MsoNormal" style="mso-list:l0 level1 lfo1;tab-stops:list 36.0pt;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;RPC:Completed  &lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;ul style="margin-top:0cm;"&gt; &lt;li class="MsoNormal" style="mso-list:l0 level1 lfo1;tab-stops:list 36.0pt;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;SQL:BatchCompleted  &lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;ul style="margin-top:0cm;"&gt; &lt;li class="MsoNormal" style="mso-list:l0 level1 lfo1;tab-stops:list 36.0pt;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;SP:StmtCompleted &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;SQL Server 2000: &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;ul style="margin-top:0cm;"&gt; &lt;li class="MsoNormal" style="mso-list:l0 level1 lfo1;tab-stops:list 36.0pt;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;RPC:Completed  &lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;ul style="margin-top:0cm;"&gt; &lt;li class="MsoNormal" style="mso-list:l0 level1 lfo1;tab-stops:list 36.0pt;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;SQL:BatchCompleted &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;The best time to create a trace file is when actual users are on the server doing real work. Not you running a few queries right and left.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;A workload should be representative of your typical load on the server.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;Starting the profiler &lt;b style="mso-bidi-font-weight:normal;"&gt;WILL&lt;/b&gt; have an effect on the performance of the server.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;I also recommend increasing the max file size, since the profiler will create a new file once it reaches the limit.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;I normally increase it to 100MB. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;font size="4"&gt;Running the Trace: &lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;/p&gt;&lt;/b&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Click on the run button and go back to Management Studio and run the following script: &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;USE&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; AdventureWorks &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;City&lt;/span&gt;&lt;span style="font-size:10pt;color:gray;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;,&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; NumberOfOrders &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;count&lt;/span&gt;&lt;span style="color:gray;"&gt;(*) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;FROM&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; DTA_Individual i&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_Customer c&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;ON&lt;/span&gt; i&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;=&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;AND&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerType &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:red;"&gt;&amp;#39;I&amp;#39; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_CustomerAddress ca&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;ON&lt;/span&gt; ca&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;=&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_Address a &lt;span style="color:blue;"&gt;ON&lt;/span&gt; a&lt;span style="color:gray;"&gt;.&lt;/span&gt;AddressID &lt;span style="color:gray;"&gt;=&lt;/span&gt; ca&lt;span style="color:gray;"&gt;.&lt;/span&gt;AddressID &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_SalesOrderHeader sh &lt;span style="color:blue;"&gt;ON&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;=&lt;/span&gt; sh&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_SalesOrderDetail sd &lt;span style="color:blue;"&gt;ON&lt;/span&gt; sd&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderID &lt;span style="color:gray;"&gt;=&lt;/span&gt; sh&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderID &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_Product p &lt;span style="color:blue;"&gt;ON&lt;/span&gt; p&lt;span style="color:gray;"&gt;.&lt;/span&gt;ProductID &lt;span style="color:gray;"&gt;=&lt;/span&gt; sd&lt;span style="color:gray;"&gt;.&lt;/span&gt;ProductID &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; StateProvinceID &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT&lt;/span&gt; StateProvinceID &lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Person&lt;span style="color:gray;"&gt;.&lt;/span&gt;StateProvince &lt;span style="color:blue;"&gt;WHERE&lt;/span&gt; StateProvinceCode &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:red;"&gt;&amp;#39;CA&amp;#39;&lt;/span&gt;&lt;span style="color:gray;"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GROUP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;BY&lt;/span&gt; City &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;ORDER&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;BY&lt;/span&gt; 2 &lt;span style="color:blue;"&gt;DESC &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; i&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID&lt;span style="color:gray;"&gt;,&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;ModifiedDate&lt;span style="color:gray;"&gt;,&lt;/span&gt; City &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;FROM&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; DTA_Individual i&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_Customer c&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;ON&lt;/span&gt; i&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;=&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;AND&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerType &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:red;"&gt;&amp;#39;I&amp;#39; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_CustomerAddress ca&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;ON&lt;/span&gt; ca&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;=&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_Address a &lt;span style="color:blue;"&gt;ON&lt;/span&gt; a&lt;span style="color:gray;"&gt;.&lt;/span&gt;AddressID &lt;span style="color:gray;"&gt;=&lt;/span&gt; ca&lt;span style="color:gray;"&gt;.&lt;/span&gt;AddressID &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; i&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;=&lt;/span&gt; 13311 &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; i&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID&lt;span style="color:gray;"&gt;,&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;TerritoryID&lt;span style="color:gray;"&gt;,&lt;/span&gt; City &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;FROM&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; DTA_Individual i&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_Customer c&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;ON&lt;/span&gt; i&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;=&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;AND&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerType &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:red;"&gt;&amp;#39;I&amp;#39; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_CustomerAddress ca&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;ON&lt;/span&gt; ca&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;span style="color:gray;"&gt;=&lt;/span&gt; c&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;JOIN&lt;/span&gt; DTA_Address a &lt;span style="color:blue;"&gt;ON&lt;/span&gt; a&lt;span style="color:gray;"&gt;.&lt;/span&gt;AddressID &lt;span style="color:gray;"&gt;=&lt;/span&gt; ca&lt;span style="color:gray;"&gt;.&lt;/span&gt;AddressID &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; StateProvinceID &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT&lt;/span&gt; StateProvinceID &lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Person&lt;span style="color:gray;"&gt;.&lt;/span&gt;StateProvince &lt;span style="color:blue;"&gt;WHERE&lt;/span&gt; StateProvinceCode &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:red;"&gt;&amp;#39;CA&amp;#39;&lt;/span&gt;&lt;span style="color:gray;"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;ORDER&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;BY&lt;/span&gt; i&lt;span style="color:gray;"&gt;.&lt;/span&gt;CustomerID&lt;span style="color:gray;"&gt;,&lt;/span&gt; City &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;When you go back to the profiler, you will see everything that was sent to the server: &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image008_4.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="402" alt="clip_image008" src="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image008_thumb_1.jpg" width="636" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;When you will be running this for real (on your production server), you have to let the trace run for a while; I let it run for 20-30 minutes.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;When you feel you have a good workload, you can stop the trace and quit the profiler. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;font size="4"&gt;Running the Database Tuning Advisor: &lt;/font&gt;&lt;/span&gt;&lt;/b&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;To begin, open the DTA,&lt;a name="procedureToggleEFBHA"&gt;&lt;/a&gt; From the Windows &lt;span style="mso-bidi-font-weight:bold;"&gt;Start&lt;/span&gt; menu, point to &lt;span style="mso-bidi-font-weight:bold;"&gt;All Programs&lt;/span&gt;, point to &lt;span style="mso-bidi-font-weight:bold;"&gt;Microsoft SQL Server 2005&lt;/span&gt;, point to &lt;span style="mso-bidi-font-weight:bold;"&gt;Performance Tools&lt;/span&gt;, and then click &lt;span style="mso-bidi-font-weight:bold;"&gt;Database Engine Tuning Advisor&lt;/span&gt;.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;In the &lt;span style="mso-bidi-font-weight:bold;"&gt;Connect to Server&lt;/span&gt; dialog box, verify the default settings, and then click &lt;span style="mso-bidi-font-weight:bold;"&gt;Connect&lt;/span&gt;. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;By default, Database Engine Tuning Advisor opens to the configuration in the following illustration: &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image010_4.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="361" alt="clip_image010" src="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image010_thumb_1.jpg" width="511" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Before you can start the DTA, you need to select the trace file and select the database(s) to tune. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Click the &lt;span style="mso-bidi-font-weight:bold;"&gt;Start Analysis&lt;/span&gt; button on the toolbar. While Database DTA is analyzing the workload, you can monitor the status on the &lt;span style="mso-bidi-font-weight:bold;"&gt;Progress&lt;/span&gt; tab. When tuning is complete, the &lt;span style="mso-bidi-font-weight:bold;"&gt;Recommendations&lt;/span&gt; tab is displayed. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image012_4.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="362" alt="clip_image012" src="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image012_thumb_1.jpg" width="513" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;After a couple of minutes (could take a while depending on the trace file size) the Recommendations tab is displayed and you can see the recommendations: &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image014_4.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="360" alt="clip_image014" src="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image014_thumb_1.jpg" width="513" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;At this point, you have two choices; you can apply the recommendations directly or save them to a file.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;I personally save the recommendation to file because I like to see what suggestions were made and I try to understand them. &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;You do this by clicking &lt;b&gt;Save Recommendations&lt;/b&gt; on the &lt;b&gt;Actions&lt;/b&gt; menu. You will have to execute the file in Management Studio to implement the changes. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image016_4.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="155" alt="clip_image016" src="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image016_thumb_1.jpg" width="250" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;For this demo, it is OK to apply them.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;If you apply the recommendation directly from the DTA, you will have more problems removing them afterwards. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;font size="4"&gt;What was created? &lt;/font&gt;&lt;/span&gt;&lt;/b&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Once you have implemented the recommendations you can see what was created by looking in the Indexes and the Statistics level for a given table in the Object Explorer. &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;All objects created by the DTA starts with “_dta”. &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image018_4.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="386" alt="clip_image018" src="http://www.sqlprof.com/blogs/sqlserver/WindowsLiveWriter/HowtoTuneaDatabaseUsingtheDatabaseTuning_7D10/clip_image018_thumb_1.jpg" width="306" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/p&gt;&lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;font size="4"&gt;Cleaning up: &lt;/font&gt;&lt;/span&gt;&lt;/b&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;You can run this script to clean up our mess: &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;USE&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; AdventureWorks &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; DTA_Individual &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; DTA_Customer &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; DTA_CustomerAddress &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; DTA_Address &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; DTA_Vendor &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; DTA_VendorContact &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; DTA_Employee &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; DTA_SalesOrderHeader &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; DTA_SalesOrderDetail &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; DTA_Product &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Hope this was useful, &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Eric Vaillancourt &lt;/span&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://www.sqlprof.com"&gt;http://www.sqlprof.com&lt;/a&gt; &lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:974b9ebd-d997-42d7-a45a-0545fdecd9a1" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati : &lt;a href="http://technorati.com/tags/SQL%20Server%202005" rel="tag"&gt;SQL Server 2005&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Tuning" rel="tag"&gt;Tuning&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Profiler" rel="tag"&gt;Profiler&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Index" rel="tag"&gt;Index&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Statistics" rel="tag"&gt;Statistics&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Performance" rel="tag"&gt;Performance&lt;/a&gt;&lt;/div&gt;</description></item><item><title>Avoid using local variables in your Select statements</title><link>http://www.sqlprof.com/blogs/sqlserver/archive/2008/03/29/avoid-using-local-variables-in-your-select-statements.aspx</link><pubDate>Sat, 29 Mar 2008 18:36:04 GMT</pubDate><guid isPermaLink="false">f1c11735-f88c-466b-aadf-9e672bf81be1:20</guid><dc:creator>Eric</dc:creator><description>&lt;p&gt;&lt;span style="font-size:10pt;line-height:140%;font-family:arial;"&gt;People are always surprised when I tell that their queries will run slower when they use local variables in their queries. &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;Let me explain: If you use a local variable in a query predicate instead of a parameter or literal, the optimizer resorts to a guesstimate for selectivity of the predicate. Use parameters or literals in the query instead of local variables, and the optimizer will do a better selecting a query plan. For example, execute both of these queries. &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;The first one uses a local variable and the second one a literal:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;line-height:140%;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;use&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; adventureworks&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:green;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;--first one with a local varaiable&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;declare&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; @StartOrderDate &lt;span style="color:blue;"&gt;datetime&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;set&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; @StartOrderDate &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:red;"&gt;&amp;#39;20040731&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:red;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;select&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;from&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderHeader hdr&lt;span style="color:gray;"&gt;,&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderDetail dtl&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; hdr&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderID &lt;span style="color:gray;"&gt;=&lt;/span&gt; dtl&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderId&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:gray;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;AND&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; hdr&lt;span style="color:gray;"&gt;.&lt;/span&gt;OrderDate &lt;span style="color:gray;"&gt;&amp;gt;=&lt;/span&gt; @StartOrderDate&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:green;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;--secondeone with a literal&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderHeader hdr&lt;span style="color:gray;"&gt;,&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderDetail dtl&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; hdr&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderID &lt;span style="color:gray;"&gt;=&lt;/span&gt; dtl&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderId&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:10pt;color:gray;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:en-us;mso-fareast-language:en-us;mso-bidi-language:ar-sa;"&gt;AND&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;mso-fareast-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:en-us;mso-fareast-language:en-us;mso-bidi-language:ar-sa;"&gt; hdr&lt;span style="color:gray;"&gt;.&lt;/span&gt;OrderDate &lt;span style="color:gray;"&gt;&amp;gt;=&lt;/span&gt; &lt;span style="color:red;"&gt;&amp;#39;20040731&amp;#39;&lt;/span&gt;&lt;/span&gt;  &lt;p&gt;The number of rows from Sales.SalesOrderHeader that the optimizer estimates will qualify vs. the condition hdr.OrderDate &amp;gt;= @StartOrderDate is 9439.5, which is exactly 30% of the size of the table. (the observations that follow are based on my SQL Server 2005 version; your results may differ depending on your SQL Server version, available memory, etc.).  &lt;p&gt;The cardinality of the result set for the predicate &amp;quot;hdr.OrderDate &amp;gt;= &amp;#39;20040731&amp;#39;&amp;quot; is estimated as 40 for a selectivity of 0.13%. The plan chosen for this query uses a nested loop join instead of a merge join because of this improved estimate. &lt;p&gt;&lt;a href="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/AvoidusinglocalvariablesinyourSelectstat_CC80/image_2.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="332" alt="image" src="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/AvoidusinglocalvariablesinyourSelectstat_CC80/image_thumb.png" width="464" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;To force SQL Server to optimize a query every time it is run, and use the values of local variables to estimate cardinality and cost during optimization of the query, add the RECOMPILE query hint to the query. For example, modify the first of the two preceding example queries shown to: &lt;p&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;FROM&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderHeader hdr&lt;span style="color:gray;"&gt;,&lt;/span&gt; Sales&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderDetail dtl&lt;/span&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; hdr&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderID &lt;span style="color:gray;"&gt;=&lt;/span&gt; dtl&lt;span style="color:gray;"&gt;.&lt;/span&gt;SalesOrderId&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;color:gray;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;AND&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; hdr&lt;span style="color:gray;"&gt;.&lt;/span&gt;OrderDate &lt;span style="color:gray;"&gt;&amp;gt;=&lt;/span&gt; @StartOrderDate&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;span style="font-size:10pt;color:blue;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;OPTION&lt;/span&gt;&lt;span style="font-size:10pt;color:gray;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;(&lt;/span&gt;&lt;span style="font-size:10pt;color:blue;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;RECOMPILE&lt;/span&gt;&lt;span style="font-size:10pt;color:gray;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;)&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;This eliminates the problem of bad estimates due to local variables, at the cost of recompiling the query every time you run it.&amp;nbsp; Compilation overhead can be quite high, especially for frequently-run, small queries. To avoid this overhead, further modify your application to use parameterized batches or stored procedures instead of dynamic SQL.&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;To eliminate the use of local variables, consider :&lt;/p&gt; &lt;ol&gt; &lt;li&gt; &lt;div class="MsoNormal" style="mso-layout-grid-align:none;"&gt;Rewriting the query to use literals directly in queries instead of assigning them to variables and then using the variables in the queries;&lt;/div&gt;&lt;/li&gt; &lt;li&gt; &lt;div class="MsoNormal" style="mso-layout-grid-align:none;"&gt;Using &lt;b&gt;sp_executesql&lt;/b&gt; or API server cursors with parameters that replace your use of local variables;&lt;/div&gt;&lt;/li&gt; &lt;li&gt; &lt;div class="MsoNormal" style="mso-layout-grid-align:none;"&gt;Using a stored procedure with parameters that replace your use of local variables.&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;Hope this helps,&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;Eric Vaillancourt&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&amp;nbsp;&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4d6b1a1a-4665-481e-8429-c9fd98f5ed0f" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati : &lt;a href="http://technorati.com/tags/SQL%20Server%202005" rel="tag"&gt;SQL Server 2005&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Tuning" rel="tag"&gt;Tuning&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Statistics" rel="tag"&gt;Statistics&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Performance" rel="tag"&gt;Performance&lt;/a&gt;&lt;/div&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;Reference : &lt;a title="http://www.microsoft.com/technet/prodtechnol/sql/2005/qrystats.mspx" href="http://www.microsoft.com/technet/prodtechnol/sql/2005/qrystats.mspx" target="_blank"&gt;http://www.microsoft.com/technet/prodtechnol/sql/2005/qrystats.mspx&lt;/a&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;/p&gt;</description></item><item><title>Understanding SET STATISTICS IO and SET STATISTICS TIME</title><link>http://www.sqlprof.com/blogs/sqlserver/archive/2008/03/23/understanding-set-statistics-io-and-set-statistics-time.aspx</link><pubDate>Sun, 23 Mar 2008 14:15:07 GMT</pubDate><guid isPermaLink="false">f1c11735-f88c-466b-aadf-9e672bf81be1:15</guid><dc:creator>Eric</dc:creator><description>&lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Today, I want to talk about two commands that are often overlooked.&amp;nbsp; &lt;a href="http://msdn2.microsoft.com/en-us/library/ms184361.aspx?lc=1033" target="_blank"&gt;SET STATISTICS IO&lt;/a&gt; and &lt;a href="http://msdn2.microsoft.com/en-us/library/ms190287.aspx?lc=1033" target="_blank"&gt;SET STATISTICS TIME&lt;/a&gt; these two commands are very useful when comes time to tune a query.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Tuning a query seems simple enough. In essence, we want our searches to run faster.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;When I teach my class on “Optimizing SQL Server” I realize that many people find it difficult to accomplish this task.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;While there are many reasons why query tuning is difficult, this article will concentrate on one aspect.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;And that is that query tuning takes place in an environment that is often changing from second to second, making it hard to really know what exactly is going on.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;When you run a query, different server resources are used. One of those resources is the CPU time. If you run the same query over and over again, the CPU time needed to run the query will remain very close from one execution to other. I am not talking about the total time it takes to run query from the start to the end, but the amount of CPU time needed to run the query.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Another resource that the Server needs is IO. Whenever you run a query, the server must retrieve data from memory (logical reads) or from the disk (physical reads).&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;Using high CPU and IO resources will result in slow query performance.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;So your goal should be to rewrite your queries in such a way that they use less CPU and IO resources. If you accomplish this, then the performance of your query will improve.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Both the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms184361.aspx?lc=1033" target="_blank"&gt;SET STATISTICS IO&lt;/a&gt; and the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms190287.aspx?lc=1033" target="_blank"&gt;SET STATISTICS TIME&lt;/a&gt; Transact-SQL commands have been around a long time. But for some reason, they are often ignored.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Both commands can be “turned on” using Transact-SQL commands or by setting the appropriate connection properties in Options dialog from the tools menu in Management Studio.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10.5pt;font-family:&amp;#39;Trebuchet MS&amp;#39;;"&gt;&lt;a href="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image002_8.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="343" alt="clip_image002" src="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image002_thumb_3.jpg" width="585" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;By default, these settings are not turned on.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;The SET STATISTICS IO and the SET STATISTICS TIME commands act like settings, turning on and off various reported information on the resources our queries use.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;So let’s look at an example of how use these commands.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;To begin our example, start Management Studio and connect to a SQL Server. For this example, we will use the sample database provided by with SQL Server 2005 and that is AdventureWorks.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;So start by making AdventureWorks your default database.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Next, run this query: &lt;/span&gt;&lt;/p&gt; &lt;div style="border-right:medium none;padding-right:0cm;border-top:#c8cdde 1pt solid;padding-left:0cm;background:#dddddd;padding-bottom:0cm;border-left:medium none;padding-top:4pt;border-bottom:medium none;mso-element:para-border-div;mso-border-top-alt:solid #c8cdde .75pt;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;"&gt;USE AdventureWorks;&lt;/span&gt;  &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;vertical-align:top;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;"&gt;GO&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;vertical-align:top;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;"&gt;SELECT * FROM Person.Contact;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;vertical-align:top;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;"&gt;GO&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Normally this query should return 19972 rows.&amp;nbsp; &lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Now, let’s run the same query, but this time, let&amp;#39;s run the SET STATISTICS IO and the SET STATISTICS TIME commands before we run the query.&amp;nbsp; &lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Before we begin our example, run these two commands &lt;a href="http://msdn2.microsoft.com/en-us/library/ms187762.aspx" target="_blank"&gt;DBCC DROPCLEANBUFFERS&lt;/a&gt; and &lt;a href="http://msdn2.microsoft.com/en-us/library/ms174283.aspx" target="_blank"&gt;DBCC FREEPROCCACHE&lt;/a&gt; (don’t run these on a production server) first. These two commands will clear out SQL Server’s data and procedure cache.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;div style="border-right:medium none;padding-right:0cm;border-top:#c8cdde 1pt solid;padding-left:0cm;background:#dddddd;padding-bottom:0cm;border-left:medium none;padding-top:4pt;border-bottom:medium none;mso-element:para-border-div;mso-border-top-alt:solid #c8cdde .75pt;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-bidi-font-size:10.0pt;"&gt;DBCC DROPCLEANBUFFERS&lt;br /&gt;DBCC FREEPROCCACHE&lt;/span&gt;&lt;/div&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-size:12.0pt;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-size:12.0pt;"&gt;Now, enter and run the following Transact-SQL commands:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;div style="border-right:medium none;padding-right:0cm;border-top:#c8cdde 1pt solid;padding-left:0cm;background:#dddddd;padding-bottom:0cm;border-left:medium none;padding-top:4pt;border-bottom:medium none;mso-element:para-border-div;mso-border-top-alt:solid #c8cdde .75pt;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-bidi-font-size:10.0pt;"&gt;SET STATISTICS IO ON&lt;br /&gt;SET STATISTICS TIME ON&lt;/span&gt;&lt;/div&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-size:12.0pt;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-size:12.0pt;"&gt;Once you have done this, then run this command again:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;div style="border-right:medium none;padding-right:0cm;border-top:#c8cdde 1pt solid;padding-left:0cm;background:#dddddd;padding-bottom:0cm;border-left:medium none;padding-top:4pt;border-bottom:medium none;mso-element:para-border-div;mso-border-top-alt:solid #c8cdde .75pt;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;"&gt;SELECT * FROM Person.Contact;&lt;/span&gt;  &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;vertical-align:top;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;"&gt;GO&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;After you run these command, you will see new information in the message tab that you did not see before. &lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;a href="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image004_4.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="403" alt="clip_image004" src="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image004_thumb_1.jpg" width="513" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;(The results you get may vary, but we will talk about this below as we explain everything you see above.)&lt;br /&gt;&lt;br /&gt;Let me explain what it all means:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;SET STATISTICS TIME Results:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;“SQL Server parse and compile time:” tells us how much CPU time and total time it took SQL Server to parse and compile our T-SQL statement.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;In my case, it took 0 ms. of CPU time, and a total time of 359 ms. of elapsed time. Your CPU time will probably vary because your server is different than mine.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;If you re-execute the query, again without clearing the cache (as recommended above), most likely both instances of CPU and compile time will be 0, as the cached query plan will be reused, so no new compile time is required.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;This is not too important, what is of interest to us is the time information displayed at the bottom of the query’s output. Here is it is again:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="mso-layout-grid-align:none;"&gt;&lt;span style="font-size:8pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;SQL Server Execution Times:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:8pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CPU time = 125 ms,&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;elapsed time = 1112 ms.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:8pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;What this tells us is how much CPU time was used to execute the query, and how long the query took to run.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;The CPU time is a somewhat consistent measurement of the amount of CPU resources it takes for your query to run, and this is relatively independent of how busy your CPU is. &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;The elapsed time number is a measurement of how long the query took to execute (not counting the time for locks or reads). This number will vary a lot because depending on the load on your server.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Because the CPU time is relatively consistent, this is what you should use to determine whether the changes you make in your queries, are helping or making things worse.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;SET STATISTICS IO Results:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Table &amp;#39;Contact&amp;#39;. Scan count 1, logical reads 561, physical reads 1, read-ahead reads 559, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;This is not all useful; let me try to explain what it means.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;table class="MsoNormalTable" style="border-right:medium none;border-top:medium none;margin-left:1.15pt;border-left:medium none;border-bottom:medium none;border-collapse:collapse;mso-padding-alt:0cm 0cm 0cm 0cm;mso-table-layout-alt:fixed;mso-border-alt:solid windowtext .5pt;mso-border-insideh:.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext;" cellspacing="0" cellpadding="0"&gt;  &lt;tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes;"&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:windowtext 1pt solid;padding-left:0cm;padding-bottom:0cm;border-left:windowtext 1pt solid;width:90pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal" style="text-align:center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size:10pt;font-family:arial;mso-ansi-language:fr-ca;"&gt;Output item&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:windowtext 1pt solid;padding-left:0cm;padding-bottom:0cm;border-left:medium none;width:377.95pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal" style="text-align:center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size:10pt;font-family:arial;mso-ansi-language:fr-ca;"&gt;Meaning&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="mso-yfti-irow:1;"&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:windowtext 1pt solid;width:90pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-weight:bold;mso-ansi-language:fr-ca;"&gt;Table&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;mso-ansi-language:fr-ca;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:medium none;width:377.95pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Name of the table, in our case ‘Contact’&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="mso-yfti-irow:2;"&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:windowtext 1pt solid;width:90pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-weight:bold;mso-ansi-language:fr-ca;"&gt;Scan count&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;mso-ansi-language:fr-ca;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:medium none;width:377.95pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Refers to the number of times that tables referenced in the query have been accessed. In our example, the table in our query was only accessed 1 time. For queries that don’t include joins, this information is not too helpful. But if your query has one or more joins, then this information may be of use to you.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="background:yellow;mso-highlight:yellow;"&gt;You may want to pay attention to the Scan Count, watching to see if it is increasing or decreasing as you tune the query.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="mso-yfti-irow:3;"&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:windowtext 1pt solid;width:90pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;background:yellow;font-family:arial;mso-bidi-font-weight:bold;mso-ansi-language:fr-ca;mso-highlight:yellow;"&gt;logical reads&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;mso-ansi-language:fr-ca;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:medium none;width:377.95pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Number of pages read from the data cache.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="background:yellow;mso-highlight:yellow;"&gt;This is the most useful piece of data&lt;/span&gt; provided by the SET STATISTICS IO commands. As you probably know, before SQL Server can do anything with data, that data must be in its data cache. In addition, when SQL Server reads data from the data cache, &lt;span style="background:yellow;mso-highlight:yellow;"&gt;it reads it in 8K pages.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;A logical read is the number of pages SQL Server had to read from the data cache in order to produce the results specified by our query. The exact same number of logical reads will always occur when the same query runs against the exact same data on SQL Server.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Knowing the number of logical reads that SQL Server takes to execute a query is important because it is the one thing that never changes from one execution to another giving us the perfect reference to use when we are tuning a query to determine if you we are succeeding or failing.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;background:yellow;font-family:arial;mso-highlight:yellow;"&gt;The fewer the logical reads performed by a query, the more efficient it is, and the faster it will perform, assuming all other things are held equal.&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="mso-yfti-irow:4;"&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:windowtext 1pt solid;width:90pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-weight:bold;"&gt;physical reads&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:medium none;width:377.95pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Number of pages read from disk.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="background:yellow;mso-highlight:yellow;"&gt;This information is not too useful for query tuning&lt;/span&gt;.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;First of all, a physical read refers to when SQL Server must go to disk to get data pages it needs to put into the data cache before it can execute the query. &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;As mentioned above, all data must be in the data cache before SQL Server can execute a query. Whenever SQL Server begins to execute a query, the first thing it does is to check and see if the data pages it needs are in the data cache. &lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="mso-yfti-irow:5;"&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:windowtext 1pt solid;width:90pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-weight:bold;"&gt;read-ahead reads&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:medium none;width:377.95pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Number of pages placed into the cache for the query.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="background:yellow;mso-highlight:yellow;"&gt;Like physical reads, this information is not too useful for query tuning.&lt;/span&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;This value tells you the number of physical page reads that SQL Server performed as part of its read-ahead mechanism. To help optimize its performance, SQL Server reads physical data pages ahead of when it thinks your queries might need the data. &lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="mso-yfti-irow:6;"&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:windowtext 1pt solid;width:90pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-weight:bold;"&gt;lob &lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-weight:bold;mso-ansi-language:fr-ca;"&gt;logical reads&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;mso-ansi-language:fr-ca;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:medium none;width:377.95pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Number of &lt;b&gt;text&lt;/b&gt;, &lt;b&gt;ntext&lt;/b&gt;, &lt;b&gt;image&lt;/b&gt;, or large value type (&lt;b&gt;varchar(max)&lt;/b&gt;, &lt;b&gt;nvarchar(max)&lt;/b&gt;, &lt;b&gt;varbinary(max)&lt;/b&gt;) pages read from the data cache.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="mso-yfti-irow:7;"&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:windowtext 1pt solid;width:90pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-weight:bold;mso-ansi-language:fr-ca;"&gt;lob physical reads&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;mso-ansi-language:fr-ca;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:medium none;width:377.95pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Number of &lt;b&gt;text&lt;/b&gt;, &lt;b&gt;ntext&lt;/b&gt;, &lt;b&gt;image&lt;/b&gt; or large value type pages read from disk.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="mso-yfti-irow:8;mso-yfti-lastrow:yes;"&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:windowtext 1pt solid;width:90pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-bidi-font-weight:bold;mso-ansi-language:fr-ca;"&gt;lob read-ahead reads&lt;/span&gt;&lt;span style="font-size:10pt;font-family:arial;mso-ansi-language:fr-ca;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td style="border-right:windowtext 1pt solid;padding-right:0cm;border-top:medium none;padding-left:0cm;padding-bottom:0cm;border-left:medium none;width:377.95pt;padding-top:0cm;border-bottom:windowtext 1pt solid;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Number of &lt;b&gt;text&lt;/b&gt;, &lt;b&gt;ntext&lt;/b&gt;, &lt;b&gt;image&lt;/b&gt; or large value type pages placed into the cache for the query.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Now for a real example:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;To be honest with you, when you execute a query without a WHERE clause there’s not much you can do to tune a query because the server performs a scan on the table.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;Let’s take another example:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Execute the following code:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;div style="border-right:medium none;padding-right:0cm;border-top:#c8cdde 1pt solid;padding-left:0cm;background:#dddddd;padding-bottom:0cm;border-left:medium none;padding-top:4pt;border-bottom:medium none;mso-element:para-border-div;mso-border-top-alt:solid #c8cdde .75pt;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;"&gt;USE AdventureWorks;&lt;/span&gt;  &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;vertical-align:top;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;"&gt;GO&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;vertical-align:top;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;"&gt;SELECT * FROM Person.Contact WHERE firstname=&amp;#39;Carla&amp;#39;;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;vertical-align:top;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;"&gt;GO&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Now look at the Message tab:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image006_2.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="401" alt="clip_image006" src="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image006_thumb.jpg" width="508" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Even though we have filtered our query and the elapsed time is down (data is cached), the logical reads are still at 561.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;This means that reading 25 rows is costing us the same as in the previous example that was returning 19972 rows.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;One thing we could do to reduce the number of logical reads is to create an index on firstname (I will cover the creation of index in another article).&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;You can create an index directly in Management Studio by selecting the table in the object explorer and right clicking on the Indexes folder:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image008_2.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="370" alt="clip_image008" src="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image008_thumb.jpg" width="288" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;A new index dialog will appear:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&lt;a href="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image010_2.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="452" alt="clip_image010" src="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image010_thumb.jpg" width="504" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;Or you can execute the following code:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;div style="border-right:medium none;padding-right:0cm;border-top:#c8cdde 1pt solid;padding-left:0cm;background:#dddddd;padding-bottom:0cm;border-left:medium none;padding-top:4pt;border-bottom:medium none;mso-element:para-border-div;mso-border-top-alt:solid #c8cdde .75pt;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-bidi-font-size:10.0pt;mso-no-proof:yes;"&gt;USE [AdventureWorks]&lt;/span&gt;  &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-bidi-font-size:10.0pt;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-bidi-font-size:10.0pt;mso-no-proof:yes;"&gt;CREATE NONCLUSTERED INDEX [IDX_firstname] ON [Person].[Contact] &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-bidi-font-size:10.0pt;mso-no-proof:yes;"&gt;(&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-bidi-font-size:10.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[FirstName] ASC&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-bidi-font-size:10.0pt;mso-no-proof:yes;"&gt;)&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="border-right:medium none;padding-right:0cm;border-top:medium none;padding-left:0cm;background:#dddddd;margin-bottom:7.5pt;padding-bottom:0cm;border-left:medium none;line-height:140%;padding-top:0cm;border-bottom:medium none;mso-border-top-alt:solid #c8cdde .75pt;mso-padding-alt:4.0pt 0cm 0cm 0cm;"&gt;&lt;span style="font-size:9pt;color:#000066;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-bidi-font-size:10.0pt;mso-no-proof:yes;"&gt;GO&lt;/span&gt;&lt;span style="font-size:10pt;line-height:140%;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;Either way, you will achieve the same result.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;Now re-execute the query and look at the message tab:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;&lt;a href="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image012_2.jpg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="418" alt="clip_image012" src="http://sqlprof.com/blogs/sqlserver/WindowsLiveWriter/UnderstandingSETSTATISTICSIOandSETSTATIS_BD7B/clip_image012_thumb.jpg" width="456" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;Now that is quite an improvement…&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;Hope this was useful, feel free to post any comments.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;Eric&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;mso-no-proof:yes;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:86bb841f-5c0d-49d6-8d85-4390b3bc3d5b" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati : &lt;a href="http://technorati.com/tags/SET%20STATISTICS%20IO" rel="tag"&gt;SET STATISTICS IO&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SET%20STATISTICS%20TIME" rel="tag"&gt;SET STATISTICS TIME&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Tuning" rel="tag"&gt;Tuning&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL%20Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Performance" rel="tag"&gt;Performance&lt;/a&gt;&lt;/div&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>