<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Identifying Statistics Used by Query</title>
	<atom:link href="http://blog.sqlauthority.com/2010/07/19/sql-server-identifying-statistics-used-by-query/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2010/07/19/sql-server-identifying-statistics-used-by-query/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sat, 25 May 2013 01:31:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Ramdas</title>
		<link>http://blog.sqlauthority.com/2010/07/19/sql-server-identifying-statistics-used-by-query/#comment-80789</link>
		<dc:creator><![CDATA[Ramdas]]></dc:creator>
		<pubDate>Mon, 19 Jul 2010 13:01:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9598#comment-80789</guid>
		<description><![CDATA[Hi Marko,
Thanks for the query, interesting subject Pinal, thanks for the article.]]></description>
		<content:encoded><![CDATA[<p>Hi Marko,<br />
Thanks for the query, interesting subject Pinal, thanks for the article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phani</title>
		<link>http://blog.sqlauthority.com/2010/07/19/sql-server-identifying-statistics-used-by-query/#comment-80759</link>
		<dc:creator><![CDATA[Phani]]></dc:creator>
		<pubDate>Mon, 19 Jul 2010 07:46:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9598#comment-80759</guid>
		<description><![CDATA[I would vote for the answer that you gave in this blog post i.e., the statistics of the index that is being used to fetch the data is used. Reason is simple. You have X number of indexes defined on a table. How is SQL Server determining which index to be used? Statistics will play a role there and depending on the number of rows that are being retrieved, respective index scan/seek will be done to retrieve the data.

I go with your Answer Pinal :)]]></description>
		<content:encoded><![CDATA[<p>I would vote for the answer that you gave in this blog post i.e., the statistics of the index that is being used to fetch the data is used. Reason is simple. You have X number of indexes defined on a table. How is SQL Server determining which index to be used? Statistics will play a role there and depending on the number of rows that are being retrieved, respective index scan/seek will be done to retrieve the data.</p>
<p>I go with your Answer Pinal :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ballantyne</title>
		<link>http://blog.sqlauthority.com/2010/07/19/sql-server-identifying-statistics-used-by-query/#comment-80755</link>
		<dc:creator><![CDATA[Dave Ballantyne]]></dc:creator>
		<pubDate>Mon, 19 Jul 2010 07:38:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9598#comment-80755</guid>
		<description><![CDATA[An interesting question.  I would say that the optimizer would use any given statistic on a Sargable column to reject or accept a possible plan.  Given that the accepted plan may not reference the statistics that were use to reject another plan, in my book that does not make them &#039;unused&#039; by the query.]]></description>
		<content:encoded><![CDATA[<p>An interesting question.  I would say that the optimizer would use any given statistic on a Sargable column to reject or accept a possible plan.  Given that the accepted plan may not reference the statistics that were use to reject another plan, in my book that does not make them &#8216;unused&#8217; by the query.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marko Parkkola</title>
		<link>http://blog.sqlauthority.com/2010/07/19/sql-server-identifying-statistics-used-by-query/#comment-80733</link>
		<dc:creator><![CDATA[Marko Parkkola]]></dc:creator>
		<pubDate>Mon, 19 Jul 2010 04:29:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9598#comment-80733</guid>
		<description><![CDATA[I think one way would to be to read sys.dm_exec_query_stats into temporary table or table valued variable, then run your query and select all the rows from sys.dm_exec_query_stats which has last_execution_time greater than the one found in temp table. Use outer apply to get executed SQL statement and compare it to your query to get correct lines.

I&#039;m not really sure about this but something like this:

declare @t table (plan_handle varbinary(64), last_execution_time datetime, execution_count int)

insert into @t
select qs.plan_handle, qs.last_execution_time, execution_count
from sys.dm_exec_query_stats qs 

select *
from sys.dm_exec_query_stats 

select *
from sys.dm_exec_query_stats qs
outer apply sys.dm_exec_sql_text(qs.plan_handle) st
join @t t on t.plan_handle = qs.plan_handle
where t.last_execution_time &gt; qs.last_execution_time]]></description>
		<content:encoded><![CDATA[<p>I think one way would to be to read sys.dm_exec_query_stats into temporary table or table valued variable, then run your query and select all the rows from sys.dm_exec_query_stats which has last_execution_time greater than the one found in temp table. Use outer apply to get executed SQL statement and compare it to your query to get correct lines.</p>
<p>I&#8217;m not really sure about this but something like this:</p>
<p>declare @t table (plan_handle varbinary(64), last_execution_time datetime, execution_count int)</p>
<p>insert into @t<br />
select qs.plan_handle, qs.last_execution_time, execution_count<br />
from sys.dm_exec_query_stats qs </p>
<p>select *<br />
from sys.dm_exec_query_stats </p>
<p>select *<br />
from sys.dm_exec_query_stats qs<br />
outer apply sys.dm_exec_sql_text(qs.plan_handle) st<br />
join @t t on t.plan_handle = qs.plan_handle<br />
where t.last_execution_time &gt; qs.last_execution_time</p>
]]></content:encoded>
	</item>
</channel>
</rss>
