﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Ryan Cooper  / Tip for determining I/O Heavy Queries / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 05:14:36 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>They would not directly relate at all.  This setup uses the size of the index in its calculation to determine the impact of reading it from disk.  So, if there is no index, it obviously wouldn't be in this.However, perhaps, by adding an index recommended by that DMV and reviewed for yourself, you should see a reduction in i/o cost for other indexes related to that table using this method, and hopefully a reduction overall for that table.</description><pubDate>Tue, 07 Apr 2009 13:27:03 GMT</pubDate><dc:creator>Ryan Cooper</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>Hi all,How do the results gleaned from this setup compare to what's available in the SQL2005 "missing index" dynamic management views?</description><pubDate>Tue, 07 Apr 2009 10:34:22 GMT</pubDate><dc:creator>BowlOfCereal</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>[quote][b]SanjayAttray (3/27/2009)[/b][hr]Good article, Solomon.  Will try to implement it on our siebel server. [/quote]Hello Sanjay and thanks.  However, the author of this article is Ryan Cooper so he should be getting your compliment :-).</description><pubDate>Fri, 27 Mar 2009 11:40:02 GMT</pubDate><dc:creator>Solomon Rutzky</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>Good article, Solomon.  Will try to implement it on our siebel server.  Siebel with SQL server ! ! !  is like a deadly combination.  Performance had been an issue off late. (by the way, this is a new project attached to me on new company acquisition)</description><pubDate>Fri, 27 Mar 2009 11:21:58 GMT</pubDate><dc:creator>SanjayAttray</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>Hi Solomon,I had already changed the EventInfo field to 4000, sorry I didn't mention that in my reply. The workaround you gave is working great, thanks a lot!!</description><pubDate>Fri, 09 Nov 2007 11:40:59 GMT</pubDate><dc:creator>Kangana Beri</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>[quote][b]Gary G (11/9/2007)[/b][hr]Do you know anyway to actually capture the SQL being executed?[/quote]Hey again, Gary.  Now, some events simply do not offer that much info, unfortunately.  However, I was able to modify the UPDATE statement to include the only other insight into the executed SQL that I am aware of (check out the [b]sys.dm_exec_sql_text(sql_handle)[/b] dynamic management view).  Just replace the UPDATE statement you have completely with this one (differences are the SET and the 3 lines between CROSS JOIN and WHERE):[code]  UPDATE tt  SET    tt.TextData = COALESCE(info.EventInfo,'') + '  --SQL-&amp;gt;  ' + COALESCE(sqltext.text, '')  FROM   dbo.TraceTable tt  INNER JOIN  inserted ins         ON   ins.RowNumber = tt.RowNumber  CROSS JOIN  #DBCCInfo info  INNER JOIN  sys.sysprocesses sp -- this table has the SPID and sql_handle         ON   sp.spid = tt.SPID -- match SPID between processes and TraceTable  CROSS APPLY sys.dm_exec_sql_text(sp.sql_handle) sqltext -- this view gets the SQL  WHERE       tt.TextData IS NULL[/code]Now, keep in mind that often enough the output from DBCC INPUTBUFFER is the same as the "text" field returned by dm_exec_sql_text().  But if it is ever different then this will certainly show it as it will always display both.Also, keep in mind that the above modification to the original UPDATE only works in SQL Server 2005.  If you want it for SQL Server 2000, then that would take a little more work to re-engineer it to use the [b]::fn_get_sql()[/b] function since there is no CROSS APPLY in SQL Server 2000.I hope this helps.Take care,Solomon...[url]http://www.SQLsharp.com/[/url]</description><pubDate>Fri, 09 Nov 2007 09:34:54 GMT</pubDate><dc:creator>Solomon Rutzky</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>Hi Solomon,Thanks for that. Once we ran the profiler &amp; trigger on the same box as the db it worked &amp; started to populate the TextData column.We are monitoring the Scan:Started event &amp; trying to capture the SQL Code that is calling the Index. The trigger popluates the TextData column but only with cursor operations eg sp_cursor, sp_cursorprepexec, sp_cursorunprepare, etc. Do you know anyway to actually capture the SQL being executed?The Profiler details i'm using are:-[b]Columns[/b]EventClassEventSubClassObjectIDIndexIDApplicationNameDatabaseIDTextDataSPIDStartTime[b]Filters[/b] Application not like     SQL Profiler    MS SQLEM    SQLAgent - Alert Engine    SQLAgent - Job Manager    SQL Query Analyzer    Spotlight on SQL Server    SQLDMO_1    MS SQLEM - Data Tools    SQLAgent - TSQL[b]DatabaseID[/b] = 7 (our Siebel db)[b]LoginName[/b] not like sa[b]ObjectID[/b] &amp;gt;= 100This profiler is capturing about 120 events per second, with only 1 user on the Siebel Application accessing the database.thanksGary</description><pubDate>Fri, 09 Nov 2007 02:29:42 GMT</pubDate><dc:creator>Gary G-461967</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>[quote][b]KB (11/8/2007)[/b][hr]But when I try to implement the trigger provided by Solomon on table IndexCapture ( I changed the table name in the trigger), the trigger gets created successfully but immediately after that an error pops up in SQL Profiler  'Failed to save trace data to table' and the trace is stopped.[/quote]Hello KB.  I think I found the problem.  In SQL Server 2005, the "EventInfo" field returned by the DBCC INPUTBUFFER command has increased in size from 255 to 4000.  So, the CREATE TABLE #DBCCInfo line should look as follows:CREATE TABLE #DBCCInfo (EventType NVARCHAR(30), Parameters INT, EventInfo NVARCHAR(4000))After adding the trigger, if the trace stops for any reason, here is a way to test the trigger:INSERT INTO dbo.TraceTable (SPID) VALUES (@@SPID)I tried this and got an error stating that data would be truncated.  That led me to look at the temp table definition and then to Books Online to see the values that DBCC INPUTBUFFER was reporting.ALSO, it appears that I was a bit hasty in posting this the first time so I am editing now to add this paragraph.  It seems that even after increasing the EventInfo field to 4000 it still gave the [b]Failed to save trace data to table.[/b] error and stops the trace.  So after more investigating I was able to work around the problem.  For some reason, adding the trigger to the table while the trace is running causes the problem.  I am not exactly sure why but that is definitely the problem.  So, the trick to fix it is to follow these steps:1) Start the trace (this creates the table)2) Pause the trace3) Run the script to create the trigger4) UN-Pause the traceI hope this helps.Take care,Solomon...[url]http://www.SQLsharp.com/[/url]</description><pubDate>Thu, 08 Nov 2007 17:58:27 GMT</pubDate><dc:creator>Solomon Rutzky</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>I have implemented Michael's article successfully. I have a sql trace running and capturing data into table IndexCapture.But when I try to implement the trigger provided by Solomon on table IndexCapture ( I changed the table name in the trigger), the trigger gets created successfully but immediately after that an error pops up in SQL Profiler  'Failed to save trace data to table' and the trace is stopped.Any ideas, why this might be happening? I am working on SQL Servr 2005 SP2, not SQL Server 2000.The table and trigger are in same the database and in the same SQL Server instance.Thanks!</description><pubDate>Thu, 08 Nov 2007 16:05:13 GMT</pubDate><dc:creator>Kangana Beri</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>[quote][b]Gary G (11/8/2007)[/b][hr]What could be causing this lack of content in the TextData column?[/quote]Hello Gary.  I don't think I mentioned this in my article, but one requirement of the trigger to provide information is that the Trace Table (and hence trigger) needs to be on the same database server (or instance) since the DBCC can only see SPIDs that are local, though there is no requirement as to which actual database it resides in.  I am not sure if this is what you already tried, but it's my initial guess without knowing what exactly you tried.  If you are still having the problem, did you use the same events that the article suggested?  Certain events will never be able to show DBCC info.Take care,Solomon...[url]http://www.SQLsharp.com/[/url]P.S.  Thank you, Ryan, for the kudos on my article :D</description><pubDate>Thu, 08 Nov 2007 08:27:47 GMT</pubDate><dc:creator>Solomon Rutzky</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>We have applied the suggestions that Ryan highlighted from Michael &amp; Solomon articles to our Siebel Database.When we look at the output from Profiler (with the trigger activated) we do not see any SQL statements.Has anyone else tried this on a Siebel database?What could be causing this lack of content in the TextData column?thanksGary</description><pubDate>Thu, 08 Nov 2007 08:11:02 GMT</pubDate><dc:creator>Gary G-461967</dc:creator></item><item><title>RE: Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>An interesting take on an old problem.I personally turn profiler on for a while, capturing "statement completed" events for the database in question.  I use a filter of reads &amp;gt;= 20 and duration &amp;gt; 1000 in order to cut down on the amount of data captured.I find it irritating that you cannot (at least in 2000) specify NOT NULL in the filters.Anyway, I usually always find some evil code that takes over a minute to run, and causes hundreds of thousands of disk reads.It is quick and dirty, but it has not failed me yet.And for those who are hyper-paranoid about the profiler causing performance problems of its own, I think that today's computers seem to be powerful enough to handle profiler for short bursts.  I would rather solve the code-related problem quickly rather than worry too much about profiler induced problems.http://cookingwithsql.com</description><pubDate>Tue, 06 Nov 2007 15:27:50 GMT</pubDate><dc:creator>Datagod-309892</dc:creator></item><item><title>Tip for determining I/O Heavy Queries</title><link>http://www.sqlservercentral.com/Forums/Topic418858-1053-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/articles/Performance+Tuning/61170/"&gt;Tip for determining I/O Heavy Queries&lt;/A&gt;[/B]</description><pubDate>Mon, 05 Nov 2007 21:52:16 GMT</pubDate><dc:creator>Ryan Cooper</dc:creator></item></channel></rss>