<?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>Strate SQL &#187; Wait Stat</title>
	<atom:link href="http://www.jasonstrate.com/index.php/category/wait-stat/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasonstrate.com</link>
	<description>Questions, answers, opinions and scripts from a SQL Server DBA</description>
	<lastBuildDate>Wed, 08 Sep 2010 13:30:00 +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>TSQL Tuesday #005 &#8211; Wait Stat Report &#8211; #TSQL2sDay</title>
		<link>http://www.jasonstrate.com/index.php/2010/04/tsql-tuesday-005-wait-stat-report-tsql2sday/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/04/tsql-tuesday-005-wait-stat-report-tsql2sday/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 12:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[DBADiagnostics]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[Wait Stat]]></category>
		<category><![CDATA[Wait Type]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/04/tsql-tuesday-005-wait-stat-report-tsql2sday/</guid>
		<description><![CDATA[Iâ€™ve been meaning to join in on the T-SQL Tuesday event for the last couple months and let the time opportunity slip by.Â  This monthâ€™s topic is reporting and its seems like a good time to get in on the event.
The great thing about reporting is that for the past few months Iâ€™ve been building [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/11/if-you-dont-know-where-youve-been/' rel='bookmark' title='Permanent Link: If You Don&#8217;t Know Where You&#8217;ve Been'>If You Don&#8217;t Know Where You&#8217;ve Been</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/01/wait-stat-categories/' rel='bookmark' title='Permanent Link: Wait Stat Categories'>Wait Stat Categories</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/06/clr_auto_event-wait-stat/' rel='bookmark' title='Permanent Link: CLR_AUTO_EVENT Wait Stat'>CLR_AUTO_EVENT Wait Stat</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F04%2Ftsql-tuesday-005-wait-stat-report-tsql2sday%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F04%2Ftsql-tuesday-005-wait-stat-report-tsql2sday%2F" height="61" width="51" /></a></div><p><a title="Stop. Report All Business Here" href="http://www.flickr.com/photos/24836642@N00/88378376/"><img style="margin: 0px 0px 10px 10px; display: inline;" src="http://static.flickr.com/13/88378376_4aa7bcdb4d.jpg" border="0" alt="Stop. Report All Business Here" width="160" height="148" align="right" /></a>Iâ€™ve been meaning to join in on the <a href="http://sqlvariant.com/wordpress/index.php/2010/04/t-sql-tuesday-005-reporting/" target="_blank">T-SQL Tuesday event</a> for the last couple months and let the time opportunity slip by.Â  This monthâ€™s topic is reporting and its seems like a good time to get in on the event.</p>
<p>The great thing about reporting is that for the past few months Iâ€™ve been building towards this very post.Â  A few months ago, I posted a blog on a process that I often use with clients and on my own machines to <a href="http://www.jasonstrate.com/index.php/2009/11/if-you-dont-know-where-youve-been/" target="_blank">capture wait stats over time</a>.Â  A while later, I followed-up with a blog on <a href="http://www.jasonstrate.com/index.php/2010/01/wait-stat-categories/" target="_blank">categorizing wait stat and providing definitions for them</a>.</p>
<p>While that was all fine and good, I hadnâ€™t provided any method to report this information in a manner that would make gathering this information useful at all.Â  Part of the delay was that shortly after the first post I realized that the reports I had intended to put up were useless.Â  They were pretty and had lots of data, but there wasnâ€™t anything you could really accomplish with them.Â  Whatâ€™s the point of useless content?</p>
<p>So, here Iâ€™ll walk through a level-100 report based on the information thatâ€™s been collected.Â  The point of this report will simply be to provide a snapshot over a number of days of all wait stats and their degree of activity on a SQL Server instance.</p>
<h4>Wait Stat Snapshot Procedure</h4>
<p>Before I can provide the report, weâ€™ll first need a stored procedure to work off of.Â  Itâ€™s a fairly simple procedure based on the previous two posts on this topic.Â  Those ones I mentioned above.</p>
<pre class="brush: sql; ">
USE [DBADiagnostics]
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N&#039;[Report].[WaitStatSnapshot]&#039;) AND type in (N&#039;P&#039;, N&#039;PC&#039;))
DROP PROCEDURE [Report].[WaitStatSnapshot]
GO

/*============================================================
Procedure:	Report.WaitStatSnapshot
Author:		Jason Strate
Date:		April 1, 2010

Synopsis:
This procedure aggregates wait stats for the selected date range.  Data is
joined with category information to provide description and action
guidance if available.

Parameters
@StartDate  : Begin date for aggregating wait stats.  Begins from the start
of the date.
@EndDate    : End date for aggregating wait stats.  Includes all data for the
end date.

============================================================
Revision History:
Date:		By			Description
------------------------------------------------------------

============================================================*/
CREATE PROCEDURE [Report].[WaitStatSnapshot]
(
@StartDate datetime
,@EndDate datetime
)
As

;WITH WaitStatCTE
AS (
SELECT COALESCE(wtc.Category, &#039;UNKNOWN&#039;) AS Category
,COALESCE(wtc.Resource, &#039;UNKNOWN&#039;) AS Resource
,wtc.Description
,wtc.Action
,wsh.WaitType
,SUM(wsh.WaitingTasksCount) AS WaitingTasksCount
,SUM(wsh.WaitTimeMs) AS WaitTimeMs
,SUM(wsh.SignalWaitTimeMs) AS SignalWaitTimeMs
FROM Monitor.WaitStatHistory wsh
INNER JOIN Resources.WaitTypeCategory wtc ON wsh.WaitType = wtc.WaitType
WHERE wsh.WaitingTasksCount &lt;&gt; 0
AND	wsh.CreateDate BETWEEN @StartDate AND DATEADD(ms, -3, DATEADD(d, 1, @EndDate))
GROUP BY COALESCE(wtc.Category, &#039;UNKNOWN&#039;)
,COALESCE(wtc.Resource, &#039;UNKNOWN&#039;)
,wsh.WaitType
,wtc.Description
,wtc.Action
)
SELECT Category
,Resource
,[Description]
,[Action]
,WaitType
,WaitTimeMs
,WaitingTasksCount
,SUM(WaitTimeMs) OVER() AS TotalWaitTimeMS
,SignalWaitTimeMs
,CAST((1.*WaitTimeMs)/SUM(WaitTimeMs) OVER() AS decimal(8,6)) AS PercentWaitTimeMS
FROM WaitStatCTE
ORDER BY WaitTimeMs DESC
GO
</pre>
<h4>Wait Stat Snapshot Report</h4>
<p>The stored procedures above returns all of the wait stats aggregated over the selected time period and displays them on the report shown below.Â  By default the report wonâ€™t display Description or Action information, but you can easily drill-down into that information.</p>
<p><a href="http://www.jasonstrate.com/images/TSQLTuesday005WaitStatReportTSQL2sDay_13F99/WaitStatReport.jpg"><img style="display: inline; border: 0px;" title="WaitStatReport" src="http://www.jasonstrate.com/images/TSQLTuesday005WaitStatReportTSQL2sDay_13F99/WaitStatReport_thumb.jpg" border="0" alt="WaitStatReport" width="464" height="176" /></a></p>
<p>The report can be downloaded here :</p>
<div id="scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:2a79478b-647f-4cd8-8294-13343acd464b" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<div><a href="http://www.jasonstrate.com/images/TSQLTuesday005WaitStatReportTSQL2sDay_13F99/Wait.Stat.Snapshot.zip" target="_blank">Wait Stat Snapshot.zip</a></div>
</div>
<p>To deploy this report, youâ€™ll have to update the data source information for the report.Â  Beyond that it should be easy to deploy and begin using.</p>
<h4>Finding Some Benefit</h4>
<p>Iâ€™ve been using this report to keep an eye on whatâ€™s happening on the SQL Servers that Iâ€™ve been monitoring for clients and it provides a good snapshot of whatâ€™s been happening since I last reviewed the server.Â  The analysis isnâ€™t too deep, but then it wouldnâ€™t be called a snapshot report.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/11/if-you-dont-know-where-youve-been/' rel='bookmark' title='Permanent Link: If You Don&#8217;t Know Where You&#8217;ve Been'>If You Don&#8217;t Know Where You&#8217;ve Been</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/01/wait-stat-categories/' rel='bookmark' title='Permanent Link: Wait Stat Categories'>Wait Stat Categories</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/06/clr_auto_event-wait-stat/' rel='bookmark' title='Permanent Link: CLR_AUTO_EVENT Wait Stat'>CLR_AUTO_EVENT Wait Stat</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/04/tsql-tuesday-005-wait-stat-report-tsql2sday/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wait Stat Categories</title>
		<link>http://www.jasonstrate.com/index.php/2010/01/wait-stat-categories/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/01/wait-stat-categories/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 13:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[DBADiagnostics]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[Wait Stat]]></category>
		<category><![CDATA[Wait Type]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/01/wait-stat-categories/</guid>
		<description><![CDATA[
A few weeks ago I posted a job that I use to track wait stats in the DBA database that I bring to a number of clients.Â  I had promised to follow-up with a couple or three reports that could be used to monitor the values that were being aggregated in those tables.
Before getting to [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/04/tsql-tuesday-005-wait-stat-report-tsql2sday/' rel='bookmark' title='Permanent Link: TSQL Tuesday #005 &#8211; Wait Stat Report &#8211; #TSQL2sDay'>TSQL Tuesday #005 &#8211; Wait Stat Report &#8211; #TSQL2sDay</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/11/if-you-dont-know-where-youve-been/' rel='bookmark' title='Permanent Link: If You Don&#8217;t Know Where You&#8217;ve Been'>If You Don&#8217;t Know Where You&#8217;ve Been</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/06/clr_auto_event-wait-stat/' rel='bookmark' title='Permanent Link: CLR_AUTO_EVENT Wait Stat'>CLR_AUTO_EVENT Wait Stat</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F01%2Fwait-stat-categories%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F01%2Fwait-stat-categories%2F" height="61" width="51" /></a></div><p><a title="Rainbow colored buckets" href="http://www.flickr.com/photos/28481088@N00/670258156/"><img style="margin: 0px 10px 10px 0px; display: inline;" src="http://static.flickr.com/1217/670258156_365e756a4b.jpg" border="0" alt="Rainbow colored buckets" width="150" height="199" align="left" /></a></p>
<p>A few weeks ago I posted a job that I use to <a href="http://www.jasonstrate.com/index.php/2009/11/if-you-dont-know-where-youve-been/" target="_blank">track wait stats in the DBA database</a> that I bring to a number of clients.Â  I had promised to follow-up with a couple or three reports that could be used to monitor the values that were being aggregated in those tables.</p>
<p>Before getting to that, though, a quick look at the output of <a href="http://msdn.microsoft.com/en-us/library/ms179984.aspx" target="_blank">sys.dm_os_wait_stats</a> might have indicated that there is a small issue with looking at the wait stats as they currently are.Â  There are a lot of wait types.Â  Specifically, my instances of SQL Server report 202 wait types for SQL Server 2005 and 485 wait types for SQL Server 2008.Â  Combining the two lists yields nearly 500 distinct wait types between SQL Server 2005 and 2008.Â  <span style="text-decoration: line-through;">Ever notice that the MISCELLANEOUS wait type appears twice for SQL Server 2008, I bet there is a good story behind that one.</span></p>
<p>With all of those wait types, there needs to be a method to group them together to assist in researching resource performance related issues.Â  Of course, you already knew this and itâ€™d probably be nice if I stopped my stalling and go to the point.</p>
<h4>Building A Wait Type Category List</h4>
<p>Before I go there, first Iâ€™d like to point out how I built the list and my plans for keeping it updated.Â  Whatâ€™s the value in a classification process, if you donâ€™t know the value of the information included?</p>
<p>To start with there are people that know the operations and internals of SQL Server much better than I do.Â  There is even a whole department at Microsoft, the CSS SQL Server Engineers,Â  that spends a lot time up to their elbows working with wait types.Â  <span style="text-decoration: line-through;">Letâ€™s be real, I mostly know what these guys have published.</span> Recently, Bob Ward has started a <a href="http://blogs.msdn.com/psssql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx" target="_blank">SQL Server Wait Type Repository</a> this is the basis for the wait type categories.Â  Why not just use this list and be done with it?Â  Well, the repository only has 22 wait types currently listed.Â  They are hitting the ones that provide the most value.Â  Their table does provide a structure and starting point for this list and I consider it <strong>the source</strong> for updates to categorizing wait types.</p>
<p>Next the list was augmented with the information provided in the <a href="http://sqlcat.com/whitepapers/archive/2007/11/19/sql-server-2005-waits-and-queues.aspx" target="_blank">SQL Server 2005 Waits and Queues</a> white paper.Â  This is a detailed white paper the provides categories and troubleshooting information for different wait types for SQL Server 2005.Â  If you havenâ€™t read this white paper you are definitely missing out and should bail on this post and go read it.</p>
<p>The third resource I used was the <a href="http://sqlserverpedia.com/wiki/Wait_Types" target="_blank">SQLServerPedia Wait Type list</a>.Â  This list covers a number of the items that arenâ€™t covered in the previous two sources and almost all of the remaining wait types.Â  And depending on when you read this, it may just look identical to the wait type category list since I am hoping to submit an update of one with the other.</p>
<p>Beyond these, there are still a few holes in the list but hopefully over time one of the three sources above or some other source will fill in the gaps and Iâ€™ll just post updates from time to time.</p>
<h4>Providing the Wait Type Category List</h4>
<p>Based on the above, here is the schema for a table that will hold all of the wait types that conforms to the structure I mentioned earlier:</p>
<pre class="brush: sql; ">

USE [DBADiagnostics]
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N&#039;[Resources].[WaitTypeCategory]&#039;) AND type in (N&#039;U&#039;))
	DROP TABLE [Resources].[WaitTypeCategory]
GO

IF  EXISTS (SELECT * FROM sys.schemas WHERE name = N&#039;Resources&#039;)
	DROP SCHEMA [Resources]
GO

IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = N&#039;Resources&#039;)
    EXEC sys.sp_executesql N&#039;CREATE SCHEMA [Resources] AUTHORIZATION [dbo]&#039;
GO

CREATE TABLE [Resources].[WaitTypeCategory]
(
[WaitType] [nvarchar](60) NOT NULL,
[Category] [varchar](50) NULL,
[Resource] [varchar](50) NULL,
[Version] [varchar](50) NULL,
[Description] [varchar](255) NULL,
[Action] [varchar](max) NULL,
CONSTRAINT [PK_WaitTypeCategory] PRIMARY KEY CLUSTERED([WaitType] ASC)
)
GO
</pre>
<p>And then there is the wait types and categories.Â  Since even WordPress thinks this is too much to add to a post, here is a script with all of it together:</p>
<div id="scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:c3184af5-fb1c-4886-bbf8-06917b37a091" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<div><a href="http://www.jasonstrate.com/images/WaitStatCategories_1DC8/WaitTypeCategory.zip" target="_blank">Wait Type Category.sql</a></div>
<p>If the week goes as planned, the reports I mentioned should be up by Wednesday.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/04/tsql-tuesday-005-wait-stat-report-tsql2sday/' rel='bookmark' title='Permanent Link: TSQL Tuesday #005 &#8211; Wait Stat Report &#8211; #TSQL2sDay'>TSQL Tuesday #005 &#8211; Wait Stat Report &#8211; #TSQL2sDay</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/11/if-you-dont-know-where-youve-been/' rel='bookmark' title='Permanent Link: If You Don&#8217;t Know Where You&#8217;ve Been'>If You Don&#8217;t Know Where You&#8217;ve Been</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/06/clr_auto_event-wait-stat/' rel='bookmark' title='Permanent Link: CLR_AUTO_EVENT Wait Stat'>CLR_AUTO_EVENT Wait Stat</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/01/wait-stat-categories/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Deadlocks on exchangeEvent and threadpool</title>
		<link>http://www.jasonstrate.com/index.php/2009/12/deadlocks-on-exchangeevent-and-threadpool/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/12/deadlocks-on-exchangeevent-and-threadpool/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 13:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[Deadlocks]]></category>
		<category><![CDATA[Parallelism]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[Wait Stat]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2009/12/deadlocks-on-exchangeevent-and-threadpool/</guid>
		<description><![CDATA[ I got to work with deadlocks quite a bit recently.Â  There were quite a few interesting ones that came up that I had the chance to research.Â  Since I like easy, Iâ€™ll start with the one that I forgot to grab the deadlock details for.
Well, maybe not all of the detailsâ€¦ in this case [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2007/09/deadlock-resources/' rel='bookmark' title='Permanent Link: Deadlock Resources'>Deadlock Resources</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/index-those-foreign-keys/' rel='bookmark' title='Permanent Link: Index Those Foreign Keys'>Index Those Foreign Keys</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/12/does-your-stored-procedure-grant-itself-permissions/' rel='bookmark' title='Permanent Link: Does Your Stored Procedure Grant Itself Permissions?'>Does Your Stored Procedure Grant Itself Permissions?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F12%2Fdeadlocks-on-exchangeevent-and-threadpool%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F12%2Fdeadlocks-on-exchangeevent-and-threadpool%2F" height="61" width="51" /></a></div><p><a href="http://www.jasonstrate.com/images/DeadlocksonexchangeEventandthreadpool_14E48/80771711.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="80771711" src="http://www.jasonstrate.com/images/DeadlocksonexchangeEventandthreadpool_14E48/80771711_thumb.jpg" border="0" alt="80771711" width="157" height="120" align="right" /></a> I got to work with deadlocks quite a bit recently.Â  There were quite a few interesting ones that came up that I had the chance to research.Â  Since I like easy, Iâ€™ll start with the one that I forgot to grab the deadlock details for.</p>
<p>Well, maybe not all of the detailsâ€¦ in this case as the title states I was looking at deadlocks with the events exchangeEvent and threadpool.Â  I managed to come across a <a href="http://blogs.msdn.com/bartd/archive/2008/09/24/today-s-annoyingly-unwieldy-term-intra-query-parallel-thread-deadlocks.aspx">post from Bart Duncan that went through and deciphered this deadlock</a>.Â  The long and the short of itâ€¦ parallelism deadlocks.</p>
<p>Bart does a better job explaining this than I can do here, especially since I didnâ€™t take the time to grab the deadlock details for review.Â  Maybe Iâ€™ll have that one the next oneâ€¦</p>
<p>Fortunately, a large part of the issue that I was reviewing for the client had to do with parallelism and so solving this issue actually occurred as a side effect of dealing with parallelism issues.Â  But I will share my little secret that I used to resolve this and most of the parallelismâ€¦</p>
<h4>Indexes!!</h4>
<p>There I said it.Â  True, you can have too many indexes.Â  But no indexes is too few.Â  No clustered indexes can lead to too many scans.Â  I could pulpit here on indexes and making sure that you have them, but Iâ€™ll save that for another time.</p>
<p>Overall, I used Bartâ€™s Workaround #1.Â  Hopefully this helpsâ€¦ direct you to a post that is more prescriptive.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2007/09/deadlock-resources/' rel='bookmark' title='Permanent Link: Deadlock Resources'>Deadlock Resources</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/index-those-foreign-keys/' rel='bookmark' title='Permanent Link: Index Those Foreign Keys'>Index Those Foreign Keys</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/12/does-your-stored-procedure-grant-itself-permissions/' rel='bookmark' title='Permanent Link: Does Your Stored Procedure Grant Itself Permissions?'>Does Your Stored Procedure Grant Itself Permissions?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/12/deadlocks-on-exchangeevent-and-threadpool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>If You Don&#8217;t Know Where You&#8217;ve Been</title>
		<link>http://www.jasonstrate.com/index.php/2009/11/if-you-dont-know-where-youve-been/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/11/if-you-dont-know-where-youve-been/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 15:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[DBADiagnostics]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[Wait Stat]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=285</guid>
		<description><![CDATA[If you donâ€™t know where youâ€™ve been, how can you expect to know where you are going.Â  Seems like such a simple little line and Iâ€™m sure many of us can look at history, politicians, and maybe that restaurant review that you didnâ€™t heed when it comes to this line.Â  But this also applies to [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/04/tsql-tuesday-005-wait-stat-report-tsql2sday/' rel='bookmark' title='Permanent Link: TSQL Tuesday #005 &#8211; Wait Stat Report &#8211; #TSQL2sDay'>TSQL Tuesday #005 &#8211; Wait Stat Report &#8211; #TSQL2sDay</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/01/wait-stat-categories/' rel='bookmark' title='Permanent Link: Wait Stat Categories'>Wait Stat Categories</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/06/but-it-wasnt-my-job-to-do-the-backups/' rel='bookmark' title='Permanent Link: But It Wasn&rsquo;t My Job To Do The Backups!?'>But It Wasn&rsquo;t My Job To Do The Backups!?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F11%2Fif-you-dont-know-where-youve-been%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F11%2Fif-you-dont-know-where-youve-been%2F" height="61" width="51" /></a></div><p>If you donâ€™t know where youâ€™ve been, how can you expect to know where you are going.Â  Seems like such a simple little line and Iâ€™m sure many of us can look at history, politicians, and maybe that restaurant review that you didnâ€™t heed when it comes to this line.Â  But this also applies to DBAs and more specifically to SQL Server.</p>
<p>In much the same wayâ€¦ if you donâ€™t know whatâ€™s been happening in your SQL Server environment, you wonâ€™t know how to resolve performance problems that have occurred on the server.Â  One of the ways I track whatâ€™s happened on a SQL Server instance is through wait stats.Â  Now if you arenâ€™t tracking wait stats and they arenâ€™t one of the first few things that you check when monitoring performance then you need to stop reading this post and <a href="http://sqlcat.com/whitepapers/archive/2007/11/19/sql-server-2005-waits-and-queues.aspx">read this instead</a>.</p>
<h6>Wait Stat Snapshots</h6>
<p>To facilitate wait stat monitoring, I typically take a snapshot of the current wait stats (<a href="http://msdn.microsoft.com/en-us/library/ms179984.aspx">sys.dm_os_wait_stats</a>) on a server every 15 minutes.Â  This is enough time that I can roll get a good idea of whatâ€™s happened from a resource perspective in a short amount of time and I can also easily roll the value up to hour, two-hour, or full day totals.Â  It gives me options â€“ we all like options.</p>
<p>As Iâ€™ve done in a number of posts in the past this new script will be setup to add to the <a href="http://stratesql.com/categories/DBADiagnostics.aspx">DBADiagnostics database</a> that Iâ€™ve blogged about before.</p>
<h6>Building the Snapshot</h6>
<p>There are two table included in the process for creating the snapshots of wait stat activity.Â  These are:</p>
<ul>
<li>Monitor.WaitStatSnapshot</li>
<li>Monitor.WaitStatHistory</li>
</ul>
<p>Here is the schema to create them:</p>
<pre class="brush: sql; ">
USE [DBADiagnostics]
GO
Â
CREATE TABLE [Monitor].[WaitStatSnapshot](
Â Â Â  [CreateDate] [datetime] NOT NULL,
Â Â Â  [WaitType] [nvarchar](60) NOT NULL,
Â Â Â  [WaitingTasksCount] [bigint] NOT NULL,
Â Â Â  [WaitTimeMs] [bigint] NOT NULL,
Â Â Â  [MaxWaitTimeMs] [bigint] NOT NULL,
Â Â Â  [SignalWaitTimeMs] [bigint] NOT NULL,
Â Â Â  CONSTRAINT [PK_Monitor_WaitStatSnapshot_CreateDateWaitType]
Â Â Â Â Â Â Â  PRIMARY KEY CLUSTERED ([CreateDate] ASC, [WaitType] ASC)
) ON [Data]
GO
Â
CREATE TABLE [Monitor].[WaitStatHistory](
Â Â Â  [CreateDate] [datetime] NOT NULL,
Â Â Â  [WaitType] [nvarchar](60) NOT NULL,
Â Â Â  [WaitingTasksCount] [bigint] NOT NULL,
Â Â Â  [WaitTimeMs] [bigint] NOT NULL,
Â Â Â  [MaxWaitTimeMs] [bigint] NOT NULL,
Â Â Â  [SignalWaitTimeMs] [bigint] NOT NULL,
Â Â Â  CONSTRAINT [PK_Monitor_WaitStatHistory_CreateDateWaitType]
Â Â Â Â Â Â Â  PRIMARY KEY CLUSTERED ([CreateDate] ASC, [WaitType] ASC)
) ON [Data]
</pre>
<p>The general process is to insert the current values from the wait stat DMV into Monitor.WaitStatSnapshot.Â  After which the delta between the last two snapshots in Monitor.WaitStatSnapshot is inserted into Monitor.WaitStatHistory.</p>
<p>If the values in the last snapshot are smaller that those in the second to last snapshot, then the insert assumes that the wait stat DMV has been reset.Â  Resetting can occur either though a SQL Server service restart or a DBCC command.</p>
<p>Either way the procedure below will accumulate a snapshot history from the wait stat DMV.Â  Of courses there are a couple parameters that provide some automated cleanup.Â  Data in Monitor.WaitStatSnapshot is cleaned up after 1 day and the data in Monitor.WaitStatHistory is cleaned up after 90 days.Â  This helps prevent the data in the DBADiagnostic database from taking over when itâ€™s neglected because everything is running perfectly.</p>
<pre class="brush: sql; ">
USE [DBADiagnostics]
GO

/*============================================================
Procedure:    Monitor.TrackWaitStats
Author:        Jason Strate
Date:        October 26, 2009

Synopsis:
    This procedure takes snapshots of wait stats and compares them with previous
    snapshots to determine a delta of changes over time.  Raw snapshot information
    is deleted on a short time span, while the delta information in the history
    table is deleted over a longer time span.

============================================================
Revision History:
Date:        By            Description
------------------------------------------------------------

============================================================*/
CREATE PROCEDURE [Monitor].[TrackWaitStats]
    (
    @SnapshotDays tinyint = 1
    ,@HistoryDays smallint = 90
    )
AS

INSERT INTO Monitor.WaitStatSnapshot
SELECT GETDATE()
    , CASE wait_type WHEN &#039;MISCELLANEOUS&#039; THEN &#039;MISCELLANEOUS&#039; ELSE wait_type END
    , SUM(waiting_tasks_count)
    , SUM(wait_time_ms)
    , SUM(max_wait_time_ms)
    , SUM(signal_wait_time_ms)
FROM sys.dm_os_wait_stats
GROUP BY CASE wait_type WHEN &#039;MISCELLANEOUS&#039; THEN &#039;MISCELLANEOUS&#039; ELSE wait_type END

;WITH WaitStatCTE
AS (
    SELECT CreateDate
        , DENSE_RANK() OVER (ORDER BY CreateDate DESC) AS HistoryID
        , WaitType
        , WaitingTasksCount
        , WaitTimeMs
        , MaxWaitTimeMs
        , SignalWaitTimeMs
    FROM Monitor.WaitStatSnapshot
    )
INSERT INTO Monitor.WaitStatHistory
SELECT w1.CreateDate
    , w1.WaitType
    , w1.WaitingTasksCount - COALESCE(w2.WaitingTasksCount,0)
    , w1.WaitTimeMs - COALESCE(w2.WaitTimeMs,0)
    , w1.MaxWaitTimeMs - COALESCE(w2.MaxWaitTimeMs,0)
    , w1.SignalWaitTimeMs - COALESCE(w2.SignalWaitTimeMs,0)
FROM WaitStatCTE w1
    LEFT OUTER JOIN WaitStatCTE w2 ON w1.WaitType = w2.WaitType
        AND w1.WaitingTasksCount &gt;= COALESCE(w2.WaitingTasksCount,0)
        AND w2.HistoryID = 2
WHERE w1.HistoryID = 1

DELETE FROM Monitor.WaitStatSnapshot
WHERE CreateDate &lt; DATEADD(d, -@SnapshotDays, GETDATE())

DELETE FROM Monitor.WaitStatHistory
WHERE CreateDate &lt; DATEADD(d, -@HistoryDays, GETDATE())
GO
</pre>
<p>There you have it.Â  While I didnâ€™t go into how you can and will use this information, the basis for collecting this data for reporting has been laid out.</p>
<p>Later this week Iâ€™ll post a follow-up to show how to report on this information and include a couple Reporting Services reports for digging into the data.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/04/tsql-tuesday-005-wait-stat-report-tsql2sday/' rel='bookmark' title='Permanent Link: TSQL Tuesday #005 &#8211; Wait Stat Report &#8211; #TSQL2sDay'>TSQL Tuesday #005 &#8211; Wait Stat Report &#8211; #TSQL2sDay</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/01/wait-stat-categories/' rel='bookmark' title='Permanent Link: Wait Stat Categories'>Wait Stat Categories</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/06/but-it-wasnt-my-job-to-do-the-backups/' rel='bookmark' title='Permanent Link: But It Wasn&rsquo;t My Job To Do The Backups!?'>But It Wasn&rsquo;t My Job To Do The Backups!?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/11/if-you-dont-know-where-youve-been/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>September PASSMN Meeting Tonight</title>
		<link>http://www.jasonstrate.com/index.php/2009/09/september-passmn-meeting-tonight/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/09/september-passmn-meeting-tonight/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 14:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[PASSMN]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Wait Stat]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=272</guid>
		<description><![CDATA[The Minnesota SQL Server user group (PASSMN) meeting is tonight at the Microsoft offices.&#160; Come check us out to network and mingle with your peers and also for the opportunity to learn some new things.
Tonightâ€™s topics are:

SQL Server and Partition Alignment
Wait-Time Based Performance Management

If you have questions or need more information on the meeting, feel [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/08/august-passmn-meeting-tonight-2/' rel='bookmark' title='Permanent Link: August PASSMN Meeting Tonight'>August PASSMN Meeting Tonight</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/08/august-passmn-meeting-tonight/' rel='bookmark' title='Permanent Link: August PASSMN Meeting Tonight'>August PASSMN Meeting Tonight</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/03/tonight-april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: Tonight April PASSMN Meeting (04/21/2009)'>Tonight April PASSMN Meeting (04/21/2009)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F09%2Fseptember-passmn-meeting-tonight%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F09%2Fseptember-passmn-meeting-tonight%2F" height="61" width="51" /></a></div><p>The Minnesota SQL Server user group (PASSMN) meeting is tonight at the Microsoft offices.&#160; Come check us out to network and mingle with your peers and also for the opportunity to learn some new things.</p>
<p>Tonightâ€™s topics are:</p>
<ul>
<li><a href="http://www.digitalconcourse.com/getdigi/dc4main.asp?p=210&amp;ConfCode=1745">SQL Server and Partition Alignment</a></li>
<li><a href="http://www.digitalconcourse.com/getdigi/dc4main.asp?p=210&amp;ConfCode=1745">Wait-Time Based Performance Management</a></li>
</ul>
<p>If you have questions or need more information on the meeting, feel free to contact me on twitter at<a href="http://twitter.com/stratesql">@StrateSQL</a> or though email at <a href="mailto:jstrate@digineer.com">jstrate@digineer.com</a>.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/08/august-passmn-meeting-tonight-2/' rel='bookmark' title='Permanent Link: August PASSMN Meeting Tonight'>August PASSMN Meeting Tonight</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/08/august-passmn-meeting-tonight/' rel='bookmark' title='Permanent Link: August PASSMN Meeting Tonight'>August PASSMN Meeting Tonight</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/03/tonight-april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: Tonight April PASSMN Meeting (04/21/2009)'>Tonight April PASSMN Meeting (04/21/2009)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/09/september-passmn-meeting-tonight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checkout PASSMN Meeting Next Week</title>
		<link>http://www.jasonstrate.com/index.php/2009/09/checkout-passmn-meeting-next-week/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/09/checkout-passmn-meeting-next-week/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 14:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[PASSMN]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Wait Stat]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=271</guid>
		<description><![CDATA[     
Just one week until the next PASSMN meeting.&#160; As I mentioned last week, this month weâ€™ll be focusing a&#160; bit on performance.&#160;&#160;&#160; And yeah, guys with lights coming out of his body means performanceâ€¦ or it might be just a great party.&#160; Come out and join the discussion with a [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/09/passmn-september-meeting-2/' rel='bookmark' title='Permanent Link: PASSMN September Meeting'>PASSMN September Meeting</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/09/september-passmn-meeting-tonight/' rel='bookmark' title='Permanent Link: September PASSMN Meeting Tonight'>September PASSMN Meeting Tonight</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/12/december-passmn-meeting-this-week/' rel='bookmark' title='Permanent Link: December PASSMN Meeting This Week'>December PASSMN Meeting This Week</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F09%2Fcheckout-passmn-meeting-next-week%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F09%2Fcheckout-passmn-meeting-next-week%2F" height="61" width="51" /></a></div><p><a href="http://stratesql.com/images/0/0/5/8/4/157902-148500/060405_nequiz_2.jpg">     <br /><img title="060405_nequiz" border="0" alt="060405_nequiz" align="right" src="http://stratesql.com/images/0/0/5/8/4/157902-148500/060405_nequiz_thumb.jpg" width="244" height="184" /></a></p>
<p>Just one week until the next PASSMN meeting.&#160; As I mentioned last week, this month weâ€™ll be focusing a&#160; bit on performance.&#160;&#160;&#160; And yeah, guys with lights coming out of his body means performanceâ€¦ or it might be just a great party.&#160; Come out and join the discussion with a snack and some great presentations.</p>
<blockquote><p><a href="http://www.digitalconcourse.com/getdigi/dc4main.asp?p=210&amp;ConfCode=1745">SQL Server and Partition Alignment &amp; Wait-Time Based Performance Management</a></p>
<p>September 15th     <br />2:30 PM Networking &amp; Social      <br />3:00 PM Announcements      <br />3:15 PM &#8211; 5:15 PM Presentations      <br />8300 Norman Center Drive      <br />9th Floor      <br />Bloomington, MN&#160; 55437</p>
</blockquote>
<p>If that wasnâ€™t enough to make you want to want to show up, here are the presentation detailsâ€¦</p>
<h6>SQL Server and Partition Alignment</h6>
<p><strong>Speaker: Jimmy May, Microsoft</strong>    <br />Now that SQL Server wait stats are formally documented &amp; DMVs are available, disk partition alignment may be the best kept secret related to database performance optimization. In combination with stripe unit size &amp; file allocation unit size, learn how you can increase I/O throughput by 10%, 30%, &amp; under some circumstances even more. Many customers are unaware of partition alignment. Even experienced disk administrators may be unfamiliar with it. Explanations are often initially met with disbelief. Engineers familiar with the topic may underestimate its importance. For example, some customers think it is useful only for Microsoft Exchange Server. In fact, partition alignment is important for all servers from which high performance is expected, especially SQL Server. Each month I encounter customers with unaligned storage. Until existing misaligned partitions created using Windows Server 2003 or Windows 2000 Server are rebuilt properly, disk partition alignment will remain a relevant technology.</p>
<p>Jimmy May&#160; is a Principal Performance Engineer for Microsoftâ€™s Assessment, Consulting, &amp; Engineering (A.C.E.) Services &amp; works for Team Lee. He is the Founder &amp; Visionary-in-Chief of SQL Server Pros &amp; was formerly the Senior Database Architect for one of the worldâ€™s largest OLTP DBs. He is a founder &amp; on the executive committees of both the Indiana Windows User Group &amp; Indianapolis Professional Association for SQL Server . Jimmy lives in Indianapolis, Indiana with his lovely bride, Phyllis, &amp; Fannie May the Wonder Dog. Subscribe to &amp; read his blog at msdn.blogs.com/jimmymay. Contact him at jimmymay@microsoft.com or aspiringgeek@live.com.</p>
<h6>Wait-Time Based Performance Management</h6>
<p><strong>Speaker: Janis Griffin, Confio</strong>    <br />Using Wait Time Analysis and Wait Types is a newer method for tuning SQL Server instances. As a result, there is often confusion on exactly what the data means. The issue typically centers around the fact the wait time data is analyzed at the wrong level or the collected wait time data is not detailed enough. This presentation will focus on these problems and review several real-life case studies of using SQL Server Wait Type data coupled with Wait-Time based performance analysis to solve the most difficult performance related issues.</p>
<p>Janis Griffin has over 20 years of DBA experience including design, development and implementation of many critical database applications. Before coming to Confio, Janis held DBA positions primarily in the Telecom Industry (15 yrs), working with both real-time network routing databases and OLTP business to business applications.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/09/passmn-september-meeting-2/' rel='bookmark' title='Permanent Link: PASSMN September Meeting'>PASSMN September Meeting</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/09/september-passmn-meeting-tonight/' rel='bookmark' title='Permanent Link: September PASSMN Meeting Tonight'>September PASSMN Meeting Tonight</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/12/december-passmn-meeting-this-week/' rel='bookmark' title='Permanent Link: December PASSMN Meeting This Week'>December PASSMN Meeting This Week</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/09/checkout-passmn-meeting-next-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PASSMN September Meeting</title>
		<link>http://www.jasonstrate.com/index.php/2009/09/passmn-september-meeting-2/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/09/passmn-september-meeting-2/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 22:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[PASSMN]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Wait Stat]]></category>
		<category><![CDATA[PASS]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=268</guid>
		<description><![CDATA[     
Just two weeks away is the next PASSMN meeting.&#160; This month weâ€™ll be focusing a&#160; bit on performance and to emphasis this point I found a picture of someone moving so fast that light emanates from their body.
SQL Server and Partition Alignment &#38; Wait-Time Based Performance Management
September 15th   [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/09/checkout-passmn-meeting-next-week/' rel='bookmark' title='Permanent Link: Checkout PASSMN Meeting Next Week'>Checkout PASSMN Meeting Next Week</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/09/september-passmn-meeting-tonight/' rel='bookmark' title='Permanent Link: September PASSMN Meeting Tonight'>September PASSMN Meeting Tonight</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2007/09/september-passmn-meeting/' rel='bookmark' title='Permanent Link: September PASSMN Meeting'>September PASSMN Meeting</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F09%2Fpassmn-september-meeting-2%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F09%2Fpassmn-september-meeting-2%2F" height="61" width="51" /></a></div><p><a href="http://stratesql.com/images/0/0/5/8/4/157902-148500/060405_nequiz_2.jpg">     <br /><img title="060405_nequiz" border="0" alt="060405_nequiz" align="right" src="http://stratesql.com/images/0/0/5/8/4/157902-148500/060405_nequiz_thumb.jpg" width="244" height="184" /></a></p>
<p>Just two weeks away is the next PASSMN meeting.&#160; This month weâ€™ll be focusing a&#160; bit on performance and to emphasis this point I found a picture of someone moving so fast that light emanates from their body.</p>
<blockquote><p><a href="http://www.digitalconcourse.com/getdigi/dc4main.asp?p=210&amp;ConfCode=1745">SQL Server and Partition Alignment &amp; Wait-Time Based Performance Management</a></p>
<p>September 15th     <br />2:30 PM Networking &amp; Social      <br />3:00 PM Announcements      <br />3:15 PM &#8211; 5:15 PM Presentations      <br />8300 Norman Center Drive      <br />9th Floor      <br />Bloomington, MN&#160; 55437</p>
</blockquote>
<p>If that wasnâ€™t enough to make you want to want to show up, here are the presentation detailsâ€¦</p>
<h6>SQL Server and Partition Alignment</h6>
<p><strong>Speaker: Jimmy May, Microsoft</strong>    <br />Now that SQL Server wait stats are formally documented &amp; DMVs are available, disk partition alignment may be the best kept secret related to database performance optimization. In combination with stripe unit size &amp; file allocation unit size, learn how you can increase I/O throughput by 10%, 30%, &amp; under some circumstances even more. Many customers are unaware of partition alignment. Even experienced disk administrators may be unfamiliar with it. Explanations are often initially met with disbelief. Engineers familiar with the topic may underestimate its importance. For example, some customers think it is useful only for Microsoft Exchange Server. In fact, partition alignment is important for all servers from which high performance is expected, especially SQL Server. Each month I encounter customers with unaligned storage. Until existing misaligned partitions created using Windows Server 2003 or Windows 2000 Server are rebuilt properly, disk partition alignment will remain a relevant technology.</p>
<p>Jimmy May&#160; is a Principal Performance Engineer for Microsoftâ€™s Assessment, Consulting, &amp; Engineering (A.C.E.) Services &amp; works for Team Lee. He is the Founder &amp; Visionary-in-Chief of SQL Server Pros &amp; was formerly the Senior Database Architect for one of the worldâ€™s largest OLTP DBs. He is a founder &amp; on the executive committees of both the Indiana Windows User Group &amp; Indianapolis Professional Association for SQL Server . Jimmy lives in Indianapolis, Indiana with his lovely bride, Phyllis, &amp; Fannie May the Wonder Dog. Subscribe to &amp; read his blog at msdn.blogs.com/jimmymay. Contact him at jimmymay@microsoft.com or aspiringgeek@live.com.</p>
<h6>Wait-Time Based Performance Management</h6>
<p><strong>Speaker: Janis Griffin, Confio</strong>    <br />Using Wait Time Analysis and Wait Types is a newer method for tuning SQL Server instances. As a result, there is often confusion on exactly what the data means. The issue typically centers around the fact the wait time data is analyzed at the wrong level or the collected wait time data is not detailed enough. This presentation will focus on these problems and review several real-life case studies of using SQL Server Wait Type data coupled with Wait-Time based performance analysis to solve the most difficult performance related issues.</p>
<p>Janis Griffin has over 20 years of DBA experience including design, development and implementation of many critical database applications. Before coming to Confio, Janis held DBA positions primarily in the Telecom Industry (15 yrs), working with both real-time network routing databases and OLTP business to business applications.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/09/checkout-passmn-meeting-next-week/' rel='bookmark' title='Permanent Link: Checkout PASSMN Meeting Next Week'>Checkout PASSMN Meeting Next Week</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/09/september-passmn-meeting-tonight/' rel='bookmark' title='Permanent Link: September PASSMN Meeting Tonight'>September PASSMN Meeting Tonight</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2007/09/september-passmn-meeting/' rel='bookmark' title='Permanent Link: September PASSMN Meeting'>September PASSMN Meeting</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/09/passmn-september-meeting-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find Query Plans That May Utilize Parallelism</title>
		<link>http://www.jasonstrate.com/index.php/2009/04/find-query-plans-that-may-utilize-parallelism/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/04/find-query-plans-that-may-utilize-parallelism/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 01:58:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[DMO]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Wait Stat]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=197</guid>
		<description><![CDATA[     
When ever I go to a new client to assist with performance issues, I inevitably download the Troubleshooting Performance Problems in SLQ Server 2005 white paper.&#160; In my opinion and many others, it is one of those documents that should be at the click of a button to open and [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/06/really-search-cache-for-execution-plans/' rel='bookmark' title='Permanent Link: Really Search Cache for Execution Plans'>Really Search Cache for Execution Plans</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/05/searching-for-plans/' rel='bookmark' title='Permanent Link: Searching for Plans'>Searching for Plans</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/05/more-parallelism/' rel='bookmark' title='Permanent Link: More Parallelism'>More Parallelism</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F04%2Ffind-query-plans-that-may-utilize-parallelism%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F04%2Ffind-query-plans-that-may-utilize-parallelism%2F" height="61" width="51" /></a></div><p><a href="http://download.microsoft.com/download/1/3/4/134644fd-05ad-4ee8-8b5a-0aed1c18a31e/TShootPerfProbs.doc">     <br /><img title="Burnt Server" border="0" alt="Burnt Server" align="right" src="http://stratesql.com/images/0/0/5/8/4/157902-148500/Burnt%20Server_eea6287c-b212-4285-9627-edd659b30b3a.png" width="137" height="152" /></a></p>
<p>When ever I go to a new client to assist with performance issues, I inevitably download the <a href="http://download.microsoft.com/download/1/3/4/134644fd-05ad-4ee8-8b5a-0aed1c18a31e/TShootPerfProbs.doc">Troubleshooting Performance Problems in SLQ Server 2005</a> white paper.&#160; In my opinion and many others, it is one of those documents that should be at the click of a button to open and I keep it handy on my desktop.</p>
<p>One of the most common wait types that I observe at clients is CXPACKET, known on the street as parallelism.&#160; And since most of these are OLTP database systems, there is a good need for looking into the causes of said wait type.</p>
<p>When Iâ€™ve identified that parallelism is the reason for the server running hot <strike>and hopefully not catching on fire</strike> I start to look at what is running or has run on the server that is utilizing parallelism.&#160; When I first starting to look for execution plans that might use parallelism, I used the query in the white paper (mentioned above) that would return back a list of all of the plans that are currently in the procedure cache that would utilize parallelism if they were selected.</p>
<p>That query is:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">SELECT</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    p.*, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    q.*,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    cp.plan_handle</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">FROM sys.dm_exec_cached_plans cp</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) p</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) q</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">WHERE cp.cacheobjtype = <span style="color: #008000">'Compiled Plan' </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">AND</span> p.query_plan.value('<span style="color: #0000ff">declare</span> <span style="color: #0000ff">namespace</span> p=<span style="color: #006080">&quot;http://schemas.microsoft.com/sqlserver/2004/07/showplan&quot;</span>;max(//p:RelOp/@Parallel)', 'float') &gt; 0</pre>
<p><!--CRLF--></div>
</div>
<p>But recently I got to thinking; and this can be a dangerous game. Do I care about a plan that is only used once? Also, is it better to first look at plans that utilize more CPU than other plans? How do I rank one plan against another plan?</p>
<p>To accomplish this, I turned to the DMV <a href="http://msdn.microsoft.com/en-us/library/ms189741.aspx">sys.dm_exec_query_stats</a>. This DMV aggregates performance statistics for cached query plans. The trouble with this DMV is that it is the query level and not the procedure level so conditional statements and looping will affect how often some SQL statements are within a procedure. I&#8217;ve put together a couple queries that combine the query above with sys.dm_exec_query_stats.</p>
<p>First, I put together the top 50 statements by average CPU utilization that is part of an execution plan that utilizes parallelism. What I like about this query is that I get an exact SQL statement to look at. Unfortunately, this isn&#8217;t an exact science because the statement with the high average CPU may not be the statement that is utilizing parallelism. On the other hand, who is going to complain if a high CPU statement without parallelism is tuned?</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">SELECT</span> TOP 50</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    OBJECT_NAME(p.objectid, p.dbid) <span style="color: #0000ff">as</span> [object_name]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,qs.execution_count</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,qs.total_worker_time</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,qs.total_logical_reads</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,qs.total_elapsed_time</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,<span style="color: #0000ff">CASE</span> statement_end_offset <span style="color: #0000ff">WHEN</span> -1 <span style="color: #0000ff">THEN</span> q.text</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">ELSE</span> SUBSTRING(q.text, statement_start_offset/2, (statement_end_offset-statement_start_offset)/2) <span style="color: #0000ff">END</span> <span style="color: #0000ff">as</span> sql_statement</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,p.query_plan</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,q.text</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,cp.plan_handle</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">FROM sys.dm_exec_query_stats qs</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    INNER JOIN sys.dm_exec_cached_plans cp <span style="color: #0000ff">ON</span> qs.plan_handle = cp.plan_handle</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) p</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) <span style="color: #0000ff">as</span> q</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">WHERE cp.cacheobjtype = <span style="color: #008000">'Compiled Plan' </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">AND</span> p.query_plan.value(<span style="color: #008000">'declare namespace p=&quot;http://schemas.microsoft.com/sqlserver/2004/07/showplan&quot;;max(//p:RelOp/@Parallel)', 'float') &gt; 0</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">ORDER BY qs.total_worker_time/qs.execution_count DESC</pre>
<p><!--CRLF--></div>
</div>
<p>The second query I have here ignores the statement level detail of sys.dm_exec_query_stats and summarizes the views at the plan_handle level. This presents some problems though since execution counts amongst all query statements isn&#8217;t always the same within a plan and which number would be best to use? Minimum executions? Maximum executions? Average executions? It all depends which side you want to error on.&#160; For the script, though, I went with maximum executions. </p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">WITH</span> cQueryStats</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">AS</span> (</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SELECT</span> qs.plan_handle</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        ,MAX(qs.execution_count) <span style="color: #0000ff">as</span> execution_count</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        ,SUM(qs.total_worker_time) <span style="color: #0000ff">as</span> total_worker_time</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        ,SUM(qs.total_logical_reads) <span style="color: #0000ff">as</span> total_logical_reads</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        ,SUM(qs.total_elapsed_time) <span style="color: #0000ff">as</span> total_elapsed_time</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    FROM sys.dm_exec_query_stats qs</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    GROUP BY qs.plan_handle</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">SELECT</span> TOP 50</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    OBJECT_NAME(p.objectid, p.dbid) <span style="color: #0000ff">as</span> [object_name] ,qs.execution_count</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,qs.total_worker_time</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,qs.total_logical_reads</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,qs.total_elapsed_time</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,p.query_plan</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,q.text</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,cp.plan_handle</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">FROM cQueryStats qs</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    INNER JOIN sys.dm_exec_cached_plans cp <span style="color: #0000ff">ON</span> qs.plan_handle = cp.plan_handle</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) p</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) <span style="color: #0000ff">as</span> q</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">WHERE cp.cacheobjtype = <span style="color: #008000">'Compiled Plan' </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">AND</span> p.query_plan.value(<span style="color: #008000">'declare namespace p=&quot;http://schemas.microsoft.com/sqlserver/2004/07/showplan&quot;;max(//p:RelOp/@Parallel)', 'float') &gt; 0</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">ORDER BY qs.total_worker_time/qs.execution_count DESC</pre>
<p><!--CRLF--></div>
</div>
<p>If you are already on SQL Server 2008, you do have the benefit of having the DMV <a href="http://msdn.microsoft.com/en-us/library/cc280701.aspx">sys.dm_exec_procedure_stats</a> at your disposal.&#160; Using this DMV will solve the problem of not having accurate execution information at the procedure level.&#160; For those blesses with SQL Server 2008, you can use this query to identify execution statistics for stored plans that utilize parallelism.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">SELECT</span> TOP 50</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    OBJECT_NAME(p.objectid, p.dbid) <span style="color: #0000ff">as</span> [object_name] </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,ps.total_worker_time/ps.execution_count <span style="color: #0000ff">as</span> avg_worker_time</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,ps.execution_count</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,ps.total_worker_time</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,ps.total_logical_reads</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,ps.total_elapsed_time</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,p.query_plan</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,q.text</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ,cp.plan_handle</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">FROM sys.dm_exec_procedure_stats ps</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    INNER JOIN sys.dm_exec_cached_plans cp <span style="color: #0000ff">ON</span> ps.plan_handle = cp.plan_handle</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) p</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) <span style="color: #0000ff">as</span> q</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">WHERE cp.cacheobjtype = <span style="color: #008000">'Compiled Plan' </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">AND</span> p.query_plan.value(<span style="color: #008000">'declare namespace p=&quot;http://schemas.microsoft.com/sqlserver/2004/07/showplan&quot;;max(//p:RelOp/@Parallel)', 'float') &gt; 0</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">ORDER BY ps.total_worker_time/ps.execution_count DESC</pre>
<p><!--CRLF--></div>
</div>
<p>If anyone has any queries that they use to address and research parallelism in their environments, I would be more than happy to see them.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/06/really-search-cache-for-execution-plans/' rel='bookmark' title='Permanent Link: Really Search Cache for Execution Plans'>Really Search Cache for Execution Plans</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/05/searching-for-plans/' rel='bookmark' title='Permanent Link: Searching for Plans'>Searching for Plans</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/05/more-parallelism/' rel='bookmark' title='Permanent Link: More Parallelism'>More Parallelism</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/04/find-query-plans-that-may-utilize-parallelism/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tonight April PASSMN Meeting (04/21/2009)</title>
		<link>http://www.jasonstrate.com/index.php/2009/03/tonight-april-passmn-meeting-04212009/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/03/tonight-april-passmn-meeting-04212009/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 15:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[DMO]]></category>
		<category><![CDATA[PASSMN]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Wait Stat]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=192</guid>
		<description><![CDATA[Looking for something fun to do?&#160; Trying to get your SQL Server to perform a little better?
There is a PASSMN (Minnesota SQL Server User Group) meeting tonight.&#160; We are meeting a little later than usual because of a room conflict.&#160; Instead of starting the meeting at 2:30 PM we are meeting at 4:30 PM.
Here are [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/04/next-tuesday-april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: Next Tuesday April PASSMN Meeting (04/21/2009)'>Next Tuesday April PASSMN Meeting (04/21/2009)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/03/april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: April PASSMN Meeting (04/21/2009)'>April PASSMN Meeting (04/21/2009)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/09/september-passmn-meeting-tonight/' rel='bookmark' title='Permanent Link: September PASSMN Meeting Tonight'>September PASSMN Meeting Tonight</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F03%2Ftonight-april-passmn-meeting-04212009%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F03%2Ftonight-april-passmn-meeting-04212009%2F" height="61" width="51" /></a></div><p>Looking for something fun to do?&#160; Trying to get your SQL Server to perform a little better?</p>
<p>There is a PASSMN (Minnesota SQL Server User Group) meeting tonight.&#160; We are meeting a little later than usual because of a room conflict.&#160; Instead of starting the meeting at 2:30 PM we are meeting at 4:30 PM.</p>
<p>Here are the sessions that we will have tonight:</p>
<blockquote><p><b>Drive Your Way to the DMV</b>      <br /><i>Speaker: Jason Strate, Digineer</i></p>
<p><b>Performance Troubleshooting with Wait Statistics       <br /></b><i>Speaker: Joe Sack, Microsoft</i></p>
</blockquote>
<p><a href="http://www.digitalconcourse.com/getdigi/DC4Main.asp?p=210&amp;ConfCode=PASSEVT20090421">Register here</a> if you are planning to come join us.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/04/next-tuesday-april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: Next Tuesday April PASSMN Meeting (04/21/2009)'>Next Tuesday April PASSMN Meeting (04/21/2009)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/03/april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: April PASSMN Meeting (04/21/2009)'>April PASSMN Meeting (04/21/2009)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/09/september-passmn-meeting-tonight/' rel='bookmark' title='Permanent Link: September PASSMN Meeting Tonight'>September PASSMN Meeting Tonight</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/03/tonight-april-passmn-meeting-04212009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>April PASSMN Meeting (04/21/2009)</title>
		<link>http://www.jasonstrate.com/index.php/2009/03/april-passmn-meeting-04212009/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/03/april-passmn-meeting-04212009/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 02:43:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[DMO]]></category>
		<category><![CDATA[PASSMN]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Wait Stat]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=178</guid>
		<description><![CDATA[Drive Your Way to the DMV &#38; Performance Troubleshooting with Wait Statistics
April 21, 2009   3:00 PM &#8211; 5:15 PM
Drive Your Way to the DMV    Speaker: Jason Strate, Digineer
Dynamic Management Views (DMVs) and Dynamic Management Functions (DMF) have been around since the release of SQL Server 2005. But for many people [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/03/tonight-april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: Tonight April PASSMN Meeting (04/21/2009)'>Tonight April PASSMN Meeting (04/21/2009)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/04/next-tuesday-april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: Next Tuesday April PASSMN Meeting (04/21/2009)'>Next Tuesday April PASSMN Meeting (04/21/2009)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/05/may-passmn-meeting-05192009/' rel='bookmark' title='Permanent Link: May PASSMN Meeting (05/19/2009)'>May PASSMN Meeting (05/19/2009)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F03%2Fapril-passmn-meeting-04212009%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F03%2Fapril-passmn-meeting-04212009%2F" height="61" width="51" /></a></div><p><a href="http://www.digitalconcourse.com/getdigi/DC4Main.asp?p=210&amp;ConfCode=PASSEVT20090421">Drive Your Way to the DMV &amp; Performance Troubleshooting with Wait Statistics</a></p>
<p>April 21, 2009   <br />3:00 PM &#8211; 5:15 PM</p>
<p><strong>Drive Your Way to the DMV</strong>    <br /><em>Speaker: Jason Strate, Digineer</em></p>
<blockquote><p>Dynamic Management Views (DMVs) and Dynamic Management Functions (DMF) have been around since the release of SQL Server 2005. But for many people DMVs and DMFs are still a mystery. Step under the hood and review some of the main DMVs and DMFs in SQL Server. From sessions to caches a walk through of some of the more useful DMVs and a practical look at what they all really mean.</p>
<p><strong>Jason Strate</strong>, Digineer Inc, has been a Database Architect for over ten years. His experiences include designing and implementing both OLAP and OLTP solutions involving clustering servers, database monitoring and tuning, analysis services, DTS/Integration Services, Reporting Services, and Notification Services. Jason is actively involved with the local PASS chapter (SQL Server User Group); he is currently serving on the Executive Board and has presented at monthly meetings. Jason contributed to Microsoftâ€™s published white paper &quot;Empowering Enterprise Solutions with SQL Server 2005 Enterprise Edition&quot; and actively blogs about SQL Server and related technologies. Also this year, Jason participated in the development of Microsoft Certification exams for SQL Server 2008, presented at the SSWUG SQL Server Launch Event and is presenting in upcoming SSWUG SQL Server Conference.</p>
</blockquote>
<p><strong>Performance Troubleshooting with Wait Statistics     <br /></strong><em>Speaker: Joe Sack, Microsoft</em></p>
<blockquote><p>When encountering a performance issue on a SQL Server instance, where do you begin? DBAs sometimes use troubleshooting methods that are biased towards past experience, instead of using a disciplined and consistent methodology. The danger of using instinct-based methods is that you may overlook the true root cause, or spend time troubleshooting less significant bottlenecks. In this session, Joe Sack will walk you through how to troubleshoot performance issues by evaluating Wait Statistics, which represent waits encountered for executed threads on a SQL Server instance. Joe will also discuss common wait type patterns seen in the field, and describe recommended next steps and resolutions. Performance troubleshooting with Wait Statistics allows you to focus on the higher priority bottlenecks, saving you time, and allowing you to apply your efforts towards the most impactful changes.</p>
<p><strong>Joe Sack</strong> is a dedicated support engineer with Microsoft Premier Field Engineering based in Minneapolis, Minnesota. Since 1997, he has been developing and supporting SQL Server environments for clients in financial services, IT consulting, manufacturing, retail and the real estate industry. He blogs about various SQL Server topics on<a href="http://blogs.msdn.com/joesack/">http://blogs.msdn.com/joesack/</a> and is the author of the Apress books SQL Server 2000 Fast Answers for DBAs and Developers, SQL Server 2005 T-SQL Recipes, and most recently SQL Server 2008 Transact-SQL Recipes.</p>
</blockquote>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/03/tonight-april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: Tonight April PASSMN Meeting (04/21/2009)'>Tonight April PASSMN Meeting (04/21/2009)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/04/next-tuesday-april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: Next Tuesday April PASSMN Meeting (04/21/2009)'>Next Tuesday April PASSMN Meeting (04/21/2009)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/05/may-passmn-meeting-05192009/' rel='bookmark' title='Permanent Link: May PASSMN Meeting (05/19/2009)'>May PASSMN Meeting (05/19/2009)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/03/april-passmn-meeting-04212009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
