<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Geek City: Accessing Distribution Statistics</title><link>http://www2.sqlblog.com/blogs/kalen_delaney/archive/2013/01/18/accessing-distribution-statistics.aspx</link><description>Distribution statistics are one of the most important sources of information that the Query Optimizer uses to determine a good query plan. In this post, I’m not going to tell you everything about distribution statistics. I’m just going to show you a few</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Geek City: Accessing Distribution Statistics</title><link>http://www2.sqlblog.com/blogs/kalen_delaney/archive/2013/01/18/accessing-distribution-statistics.aspx#47242</link><pubDate>Tue, 22 Jan 2013 15:14:25 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47242</guid><dc:creator>sfibich</dc:creator><description>&lt;p&gt;I’m guessing you already know but SQL 2008 R2 introduces a new DMV sys.dm_db_stats_properties that has almost all of the same properties as the DBCC show_statistics WITH STAT_HEADER returns. &amp;nbsp;The DMV is missing the density which I believe is no longer used by the optimizer, string index, average key length, and filtered expression. &amp;nbsp;The filtered expression column can be picked up from sys.stats filter definition column. &amp;nbsp;It’s not a perfect fit but if you can do with the average key length and the string index flag it’s a nice alternative. &amp;nbsp;You can also pull in the average record length for the 0 level index of a statistic if it has one from the sys.dm_db_index_physical_stats DMV using the DETAILED setting. &amp;nbsp;It’s not exactly the same thing but it may give some insight to the statistic. &amp;nbsp;This combination has been getting me through an high level look at statistics for a database when I’m having performance problems.&lt;/p&gt;
&lt;p&gt;I like your solution as it solves the issue for getting some of the more detailed statistics information.&lt;/p&gt;
&lt;p&gt;something like...&lt;/p&gt;
&lt;p&gt;select&lt;/p&gt;
&lt;p&gt;ddsp.*&lt;/p&gt;
&lt;p&gt;,ss.filter_definition &lt;/p&gt;
&lt;p&gt;,ss.no_recompute &lt;/p&gt;
&lt;p&gt;from&lt;/p&gt;
&lt;p&gt;sys.dm_db_stats_properties (object_id('FactInternetSales'), 2) as ddsp&lt;/p&gt;
&lt;p&gt;inner join&lt;/p&gt;
&lt;p&gt;sys.stats ss&lt;/p&gt;
&lt;p&gt;on&lt;/p&gt;
&lt;p&gt;ddsp.object_id =ss.object_id &lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;ddsp.stats_id =ss.stats_id&lt;/p&gt;
</description></item><item><title>re: Geek City: Accessing Distribution Statistics</title><link>http://www2.sqlblog.com/blogs/kalen_delaney/archive/2013/01/18/accessing-distribution-statistics.aspx#47245</link><pubDate>Tue, 22 Jan 2013 18:08:21 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47245</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;Thanks sfibich... I actually just found out about the new DMV when this issue of programmatically accessing stats info was being discussed on a private forum. Someone asked why we couldn't use sys.dm_db_stats_properties, and that was the first time I saw it! But as you say, it doesn't have everything.&lt;/p&gt;
&lt;p&gt;Thanks again&lt;/p&gt;
&lt;p&gt;Kalen&lt;/p&gt;
</description></item><item><title>Geek City: More statistics info available!</title><link>http://www2.sqlblog.com/blogs/kalen_delaney/archive/2013/01/18/accessing-distribution-statistics.aspx#48606</link><pubDate>Wed, 10 Apr 2013 01:39:35 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:48606</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;&amp;amp;#160; I just started using a new DMV (one that’s actually an ‘F’ not a ‘V’, as in Function) that gives&lt;/p&gt;
</description></item><item><title>Geek City: More statistics info available!</title><link>http://www2.sqlblog.com/blogs/kalen_delaney/archive/2013/01/18/accessing-distribution-statistics.aspx#48607</link><pubDate>Wed, 10 Apr 2013 01:40:27 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:48607</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;I just started using a new DMV (one that’s actually an ‘F’ not a ‘V’, as in Function) that gives us more&lt;/p&gt;
</description></item></channel></rss>