<?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/"
		>
<channel>
	<title>Comments on: Estimating Rows per Page</title>
	<atom:link href="http://sqlfool.com/2009/02/estimating-rows-per-page/feed/" rel="self" type="application/rss+xml" />
	<link>http://sqlfool.com/2009/02/estimating-rows-per-page/</link>
	<description>Adventures in SQL Tuning - a blog for the rest of us</description>
	<lastBuildDate>Tue, 07 Feb 2012 21:28:07 -0700</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Michelle Ufford</title>
		<link>http://sqlfool.com/2009/02/estimating-rows-per-page/comment-page-1/#comment-261</link>
		<dc:creator>Michelle Ufford</dc:creator>
		<pubDate>Wed, 11 Feb 2009 17:19:19 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=506#comment-261</guid>
		<description>Thanks, Michael!  I appreciate the comments.  I&#039;ve updated my script to include type_desc = ‘IN_ROW_DATA’, and I just downloaded SQL Internals Viewer.  It looks very interesting.  :)</description>
		<content:encoded><![CDATA[<p>Thanks, Michael!  I appreciate the comments.  I&#8217;ve updated my script to include type_desc = ‘IN_ROW_DATA’, and I just downloaded SQL Internals Viewer.  It looks very interesting.  <img src='http://sqlfool.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Swart</title>
		<link>http://sqlfool.com/2009/02/estimating-rows-per-page/comment-page-1/#comment-259</link>
		<dc:creator>Michael Swart</dc:creator>
		<pubDate>Wed, 11 Feb 2009 16:15:08 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=506#comment-259</guid>
		<description>If you&#039;re joining on sys.allocation_units and a partition has lob data, then the rows are being counted twice, but only data pages for in_row_data is being counted. This can throw off the rowsPerPages.

To fix it you could add the filter
au.type_desc = &#039;IN_ROW_DATA&#039;

or better, use a dmv:
SELECT OBJECT_NAME(i.OBJECT_ID) AS &#039;tableName&#039;
    , i.name AS &#039;indexName&#039;
    , i.type_desc
    , MAX(p.partition_number) AS &#039;partitions&#039;
    , SUM(p.row_count) AS &#039;rows&#039;
    , SUM(p.in_row_data_page_count) AS &#039;dataPages&#039;
    , SUM(p.row_count) / SUM(p.in_row_data_page_count) AS &#039;rowsPerPage&#039;
FROM sys.indexes AS i
JOIN sys.dm_db_partition_stats AS p
    ON i.OBJECT_ID = p.OBJECT_ID
    And i.index_id = p.index_id
WHERE OBJECT_NAME(i.OBJECT_ID) Not Like &#039;sys%&#039;
GROUP BY OBJECT_NAME(i.OBJECT_ID)
    , i.name
    , i.type_desc
HAVING SUM(p.in_row_data_page_count) &gt; 100
ORDER BY rowsPerPage;

And for *further* understanding of the structure of a database, I like to use SQL Internals Viewer by Danny Gould: http://www.sqlinternalsviewer.com It tells you where everything is down to the very last bit.</description>
		<content:encoded><![CDATA[<p>If you&#8217;re joining on sys.allocation_units and a partition has lob data, then the rows are being counted twice, but only data pages for in_row_data is being counted. This can throw off the rowsPerPages.</p>
<p>To fix it you could add the filter<br />
au.type_desc = &#8216;IN_ROW_DATA&#8217;</p>
<p>or better, use a dmv:<br />
SELECT OBJECT_NAME(i.OBJECT_ID) AS &#8216;tableName&#8217;<br />
    , i.name AS &#8216;indexName&#8217;<br />
    , i.type_desc<br />
    , MAX(p.partition_number) AS &#8216;partitions&#8217;<br />
    , SUM(p.row_count) AS &#8216;rows&#8217;<br />
    , SUM(p.in_row_data_page_count) AS &#8216;dataPages&#8217;<br />
    , SUM(p.row_count) / SUM(p.in_row_data_page_count) AS &#8216;rowsPerPage&#8217;<br />
FROM sys.indexes AS i<br />
JOIN sys.dm_db_partition_stats AS p<br />
    ON i.OBJECT_ID = p.OBJECT_ID<br />
    And i.index_id = p.index_id<br />
WHERE OBJECT_NAME(i.OBJECT_ID) Not Like &#8216;sys%&#8217;<br />
GROUP BY OBJECT_NAME(i.OBJECT_ID)<br />
    , i.name<br />
    , i.type_desc<br />
HAVING SUM(p.in_row_data_page_count) &gt; 100<br />
ORDER BY rowsPerPage;</p>
<p>And for *further* understanding of the structure of a database, I like to use SQL Internals Viewer by Danny Gould: <a href="http://www.sqlinternalsviewer.com" rel="nofollow">http://www.sqlinternalsviewer.com</a> It tells you where everything is down to the very last bit.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

