<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LoadRunner TnT &#187; Stored Procedures</title>
	<atom:link href="http://www.loadrunnertnt.com/tag/stored-procedures/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.loadrunnertnt.com</link>
	<description>Performance Testing, LoadRunner Tips &#38; Tricks</description>
	<lastBuildDate>Mon, 08 Mar 2010 07:57:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Find Offending SQL Bottlenecks!</title>
		<link>http://www.loadrunnertnt.com/analyze/find-offending-sql-bottlenecks/</link>
		<comments>http://www.loadrunnertnt.com/analyze/find-offending-sql-bottlenecks/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 07:54:30 +0000</pubDate>
		<dc:creator>TnT Admin</dc:creator>
				<category><![CDATA[Analyze]]></category>
		<category><![CDATA[Bottleneck]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[MS SQL]]></category>
		<category><![CDATA[SQL Statements]]></category>
		<category><![CDATA[Stored Procedures]]></category>

		<guid isPermaLink="false">http://www.loadrunnertnt.com/?p=650</guid>
		<description><![CDATA[After the tune-able parameters are changed for optimal performance, your system still fails miserably with a poor response time.  The most likely step you should take is to do a deep diagnostics on the system.  Break the system up into different components such as application server where diagnostics using probes is required, database servers where [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.loadrunnertnt.com/wp-content/uploads/2010/01/ms_sql_logo1.gif"><img class="alignleft size-full wp-image-674" title="ms_sql_logo" src="http://www.loadrunnertnt.com/wp-content/uploads/2010/01/ms_sql_logo1.gif" alt="" width="178" height="87" /></a>After the tune-able parameters are changed for optimal performance, your system still fails miserably with a poor response time.  The most likely step you should take is to do a deep diagnostics on the system.  Break the system up into different components such as application server where diagnostics using probes is required, database servers where SQL statements and stored procedures become the next to be scrutinized, etc…<span id="more-650"></span></p>
<p>In this post, we will not be covering on the diagnostics of the application server, but we will cover the basic signs of database bottlenecks at the <strong>SQL statement</strong> level.  The 1<sup>st</sup> symptom is a collective symptom that the application server (and all other servers) with the exception of the database server in the architecture are performing reasonably well.  E.g. memory available is well maintained without any exception decrease of this value, the processor % time is always low for the servers.<br />
<!--adsensestart--><br />
The 2<sup>nd</sup> symptom is a constant high utilization of the processor % time and low memory usage (page faults, page reads and available memory) in the database server.  This provides a tell-tale sign that the database server is processing some instructions, likely to be SQL statement that is taking too long.  It would not be the database buffer or SQL buffer that utilizes the memory as the consumption is low meaning reuse of the buffer is high.</p>
<p>Now with these two symptoms, you are ready to go down deeper.  Access MS SQL and run the following query:</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">SELECT</span> scheduler_id<span style="color: #66cc66;">,</span> current_tasks_count<span style="color: #66cc66;">,</span> runnable_tasks_count<br />
<span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>dm_os_schedulers <span style="color: #993333; font-weight: bold;">WHERE</span> scheduler_id <span style="color: #66cc66;">&lt;</span> <span style="color: #cc66cc;">255</span></div></div>
<p>This query will <strong>sys.dm_os_schedulers</strong> will give you information of how many runnable tasks that exists.  Values other than zero indicate that tasks are waiting to run, and high values are an indication that the CPU is bottlenecking your performance.  Another query that directly targets at SQL statement is the following:</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">SELECT</span> TOP 50 SUM<span style="color: #66cc66;">&#40;</span>qs<span style="color: #66cc66;">.</span>total_worker_time<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> total_cpu_time<span style="color: #66cc66;">,</span><br />
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">&#91;</span>TEXT<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>dm_exec_sql_text<span style="color: #66cc66;">&#40;</span>plan_handle<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
SUM<span style="color: #66cc66;">&#40;</span>qs<span style="color: #66cc66;">.</span>execution_count<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> total_execution_count<span style="color: #66cc66;">,</span><br />
COUNT<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> number_of_statements<span style="color: #66cc66;">,</span> qs<span style="color: #66cc66;">.</span>plan_handle<br />
<span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>dm_exec_query_stats qs<br />
<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> qs<span style="color: #66cc66;">.</span>plan_handle<br />
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> SUM<span style="color: #66cc66;">&#40;</span>qs<span style="color: #66cc66;">.</span>total_worker_time<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">DESC</span></div></div>
<p>This query shows which batches or procedures are consuming the most CPU and will also include the actual SQL statement. The query aggregates by a specific plan handle. If the plan handle contains more than one SQL statement you must drill into each statement to determine where the greatest CPU contribution comes from.</p>
<p>Codes illustrated in this post are taken from <a href="http://sql.dotnetbob.com/?p=96">DotNet Bob on SQL</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.loadrunnertnt.com/analyze/find-offending-sql-bottlenecks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
