10Feb/092
Estimating Rows per Page
Ever wonder how many rows you store per page? Me too. So here's the query I use to investigate this:
Select object_name(i.object_id) As 'tableName' , i.name As 'indexName' , i.type_desc , Max(p.partition_number) As 'partitions' , Sum(p.rows) As 'rows' , Sum(au.data_pages) As 'dataPages' , Sum(p.rows) / Sum(au.data_pages) As 'rowsPerPage' From sys.indexes As i Join sys.partitions As p On i.object_id = p.object_id And i.index_id = p.index_id Join sys.allocation_units As au On p.hobt_id = au.container_id Where object_name(i.object_id) Not Like 'sys%' And au.type_desc = 'IN_ROW_DATA' Group By object_name(i.object_id) , i.name , i.type_desc Having Sum(au.data_pages) > 100 Order By rowsPerPage;
What does this tell you? Well, the more rows you can fit on a page, the less IO you need to consume to retrieve those rows. It's also a good way to improve your buffer cache hit ratio (i.e. retrieve data from memory instead of disk, which is more efficient). So take a good look at those first few rows... do you have a small number of [rowsPerPage] but a large number of [rows]? If so, it may be time to look at re-designing your tables.
Happy Coding!
Michelle Ufford (aka SQLFool)
Source: http://sqlfool.com/2009/02/estimating-rows-per-page/
Tagged as: page size, rows, sys.allocation_units
2 Comments
Categories
- Business Intelligence
- Internals
- Miscellaneous
- PASS
- Performance & Tuning
- Presentations
- SQL 2008
- SQL Tips
- Syndication
- T-SQL Scripts
Subscribe to my blog!
| Like what you see? Subscribe! |
![]() |
Around the Web
Recent Tweets
- RT @Phil_Factor: SQL Server table columns under the hood http://t.co/vp7gQ77B < what a great post
- @tradney haha that's awesome :)
- OH: @AdamMachanic's #sqlpass session was one of the best I've ever seen.
Archives
- November 2011
- October 2011
- September 2011
- July 2011
- June 2011
- May 2011
- April 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- July 2010
- June 2010
- May 2010
- April 2010
- February 2010
- January 2010
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008


