<?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 the Size of a Table in SQL Server 2008</title>
	<atom:link href="http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/feed/" rel="self" type="application/rss+xml" />
	<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/</link>
	<description>Thoughts and Code from Tim Laqua</description>
	<lastBuildDate>Tue, 07 Feb 2012 18:34:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ishwar Nataraj</title>
		<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/comment-page-1/#comment-3434</link>
		<dc:creator>Ishwar Nataraj</dc:creator>
		<pubDate>Tue, 10 Jan 2012 04:32:10 +0000</pubDate>
		<guid isPermaLink="false">http://timlaqua.com/?p=250#comment-3434</guid>
		<description>sp_spaceused or sp_helpdb is also a good way to measure table growth and you can basically determie growth levels based in an exponential manner.</description>
		<content:encoded><![CDATA[<p>sp_spaceused or sp_helpdb is also a good way to measure table growth and you can basically determie growth levels based in an exponential manner.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: @billinkc</title>
		<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/comment-page-1/#comment-3300</link>
		<dc:creator>@billinkc</dc:creator>
		<pubDate>Thu, 11 Aug 2011 17:19:59 +0000</pubDate>
		<guid isPermaLink="false">http://timlaqua.com/?p=250#comment-3300</guid>
		<description>Thanks for the script, assuming I&#039;m not missing something, I think you can simplify the population of generation of rows for the insert into @tableColumn with the following query

DECLARE @TableColumn TableColumnDefinition

DECLARE
    @table_name sysname
,   @schema_name sysname
SELECT
    @table_name = &#039;TerribleTable&#039; 
,   @schema_name = &#039;mySchema&#039;


; WITH TABLE_COLUMNS AS
(
    SELECT 
        T.name AS [DataType]
    ,   SC.max_length AS [Length]
    ,   SC.name As column_name
    ,   ST.name AS table_name
    ,   schema_name(ST.schema_id) AS [schema_name]
    ,   ST.object_id
    FROM
        sys.tables ST
        INNER JOIN
            sys.columns SC
            ON SC.object_id = ST.object_id
        INNER JOIN
            sys.types T
            ON T.system_type_id = SC.system_type_id
)
, PRIMARY_KEYS AS
(
    SELECT DISTINCT
        I.object_id
    ,   IC.column_id
    ,   I.fill_factor
    ,   I.is_primary_key
    ,   C.name AS column_name
    FROM
        sys.indexes I
    INNER JOIN 
        sys.index_columns IC
        ON IC.object_id = I.object_id
        AND IC.index_id = I.index_id
    INNER JOIN
        sys.columns C
        ON C.object_id = I.object_id
        AND C.column_id = IC.column_id
    WHERE
        I.is_primary_key = 1
)
INSERT INTO @TableColumn
SELECT 
    TC.[DataType]
,   TC.[Length]
,   PK.is_primary_key AS [IsKey]
FROM
    TABLE_COLUMNS TC
    LEFT OUTER JOIN
        PRIMARY_KEYS PK
        ON PK.object_id = TC.object_id
        AND PK.column_name = TC.column_name
WHERE
    TC.table_name = @table_name
    AND TC.[schema_name] = @schema_name</description>
		<content:encoded><![CDATA[<p>Thanks for the script, assuming I&#8217;m not missing something, I think you can simplify the population of generation of rows for the insert into @tableColumn with the following query</p>
<p>DECLARE @TableColumn TableColumnDefinition</p>
<p>DECLARE<br />
    @table_name sysname<br />
,   @schema_name sysname<br />
SELECT<br />
    @table_name = &#8216;TerribleTable&#8217;<br />
,   @schema_name = &#8216;mySchema&#8217;</p>
<p>; WITH TABLE_COLUMNS AS<br />
(<br />
    SELECT<br />
        T.name AS [DataType]<br />
    ,   SC.max_length AS [Length]<br />
    ,   SC.name As column_name<br />
    ,   ST.name AS table_name<br />
    ,   schema_name(ST.schema_id) AS [schema_name]<br />
    ,   ST.object_id<br />
    FROM<br />
        sys.tables ST<br />
        INNER JOIN<br />
            sys.columns SC<br />
            ON SC.object_id = ST.object_id<br />
        INNER JOIN<br />
            sys.types T<br />
            ON T.system_type_id = SC.system_type_id<br />
)<br />
, PRIMARY_KEYS AS<br />
(<br />
    SELECT DISTINCT<br />
        I.object_id<br />
    ,   IC.column_id<br />
    ,   I.fill_factor<br />
    ,   I.is_primary_key<br />
    ,   C.name AS column_name<br />
    FROM<br />
        sys.indexes I<br />
    INNER JOIN<br />
        sys.index_columns IC<br />
        ON IC.object_id = I.object_id<br />
        AND IC.index_id = I.index_id<br />
    INNER JOIN<br />
        sys.columns C<br />
        ON C.object_id = I.object_id<br />
        AND C.column_id = IC.column_id<br />
    WHERE<br />
        I.is_primary_key = 1<br />
)<br />
INSERT INTO @TableColumn<br />
SELECT<br />
    TC.[DataType]<br />
,   TC.[Length]<br />
,   PK.is_primary_key AS [IsKey]<br />
FROM<br />
    TABLE_COLUMNS TC<br />
    LEFT OUTER JOIN<br />
        PRIMARY_KEYS PK<br />
        ON PK.object_id = TC.object_id<br />
        AND PK.column_name = TC.column_name<br />
WHERE<br />
    TC.table_name = @table_name<br />
    AND TC.[schema_name] = @schema_name</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: selcuk</title>
		<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/comment-page-1/#comment-3231</link>
		<dc:creator>selcuk</dc:creator>
		<pubDate>Wed, 27 Apr 2011 22:46:53 +0000</pubDate>
		<guid isPermaLink="false">http://timlaqua.com/?p=250#comment-3231</guid>
		<description>Thanks....</description>
		<content:encoded><![CDATA[<p>Thanks&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Walter</title>
		<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/comment-page-1/#comment-2903</link>
		<dc:creator>Walter</dc:creator>
		<pubDate>Wed, 09 Jun 2010 19:05:25 +0000</pubDate>
		<guid isPermaLink="false">http://timlaqua.com/?p=250#comment-2903</guid>
		<description>This is great Tim.  Thanks for making this calculation so much easier.</description>
		<content:encoded><![CDATA[<p>This is great Tim.  Thanks for making this calculation so much easier.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/comment-page-1/#comment-2323</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Thu, 19 Nov 2009 20:27:56 +0000</pubDate>
		<guid isPermaLink="false">http://timlaqua.com/?p=250#comment-2323</guid>
		<description>Yes, you have to run it four times (once for each index).

The Clustered Index needs all the columns specified, because the clustered index basically IS the table (that&#039;s why you can&#039;t have &quot;included columns&quot; in clustered indexes).  As for the other nonclustered indexes, you only need to specify one key column for each - if you don&#039;t have any included columns in the nonclustered indexes, you don&#039;t need to have anything other than the key column(s).  Also note for your non-unique nonclustered indexes, set IsClusteredIndexUnique to 0, it should really be called &quot;IsIndexUnique&quot;.

We&#039;re not really calculating the size of a table per-se  because a table is simply the sum of the size of its indexes (let&#039;s not talk about heaps - there&#039;s no index there, but it certainly takes up space) - we&#039;re just calculating the size of each index.</description>
		<content:encoded><![CDATA[<p>Yes, you have to run it four times (once for each index).</p>
<p>The Clustered Index needs all the columns specified, because the clustered index basically IS the table (that&#8217;s why you can&#8217;t have &#8220;included columns&#8221; in clustered indexes).  As for the other nonclustered indexes, you only need to specify one key column for each &#8211; if you don&#8217;t have any included columns in the nonclustered indexes, you don&#8217;t need to have anything other than the key column(s).  Also note for your non-unique nonclustered indexes, set IsClusteredIndexUnique to 0, it should really be called &#8220;IsIndexUnique&#8221;.</p>
<p>We&#8217;re not really calculating the size of a table per-se  because a table is simply the sum of the size of its indexes (let&#8217;s not talk about heaps &#8211; there&#8217;s no index there, but it certainly takes up space) &#8211; we&#8217;re just calculating the size of each index.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oshik</title>
		<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/comment-page-1/#comment-2322</link>
		<dc:creator>Oshik</dc:creator>
		<pubDate>Thu, 19 Nov 2009 20:15:51 +0000</pubDate>
		<guid isPermaLink="false">http://timlaqua.com/?p=250#comment-2322</guid>
		<description>Hi Tim,
i think i miss something.
let me clear my request:
 i have a partition table with 600 million rows, with 4 indexes.
one is a clustered index(three key columns)
secound - non-clustered index(non uniqe, one column)
third- non-clustered index(non uniqe, one column)
fourth- non-clustered index(non uniqe, one column).
my table has a 20 columns(varchar, int, datetime etc...).
as you meen, i need to create a TYPE(and setting the isKey to 1 for eash column index) with my table definition and run it foure time?
Thanks,
oshik.</description>
		<content:encoded><![CDATA[<p>Hi Tim,<br />
i think i miss something.<br />
let me clear my request:<br />
 i have a partition table with 600 million rows, with 4 indexes.<br />
one is a clustered index(three key columns)<br />
secound &#8211; non-clustered index(non uniqe, one column)<br />
third- non-clustered index(non uniqe, one column)<br />
fourth- non-clustered index(non uniqe, one column).<br />
my table has a 20 columns(varchar, int, datetime etc&#8230;).<br />
as you meen, i need to create a TYPE(and setting the isKey to 1 for eash column index) with my table definition and run it foure time?<br />
Thanks,<br />
oshik.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/comment-page-1/#comment-2285</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Mon, 16 Nov 2009 22:42:38 +0000</pubDate>
		<guid isPermaLink="false">http://timlaqua.com/?p=250#comment-2285</guid>
		<description>For the multiple indexes, estimate each one individually.  For non-clustered indexes, I just pretend it&#039;s a table and included columns are non-key columns - it seems to come out pretty close in my tests.  (You can just test it out against existing indexes).  As for partitioned tables and partition-aligned indexes, I&#039;ve never done anything special to account for the fact that they&#039;re partitioned.  As a matter of fact, all the examples I mentioned above were indeed partitioned tables and partition-aligned indexes.</description>
		<content:encoded><![CDATA[<p>For the multiple indexes, estimate each one individually.  For non-clustered indexes, I just pretend it&#8217;s a table and included columns are non-key columns &#8211; it seems to come out pretty close in my tests.  (You can just test it out against existing indexes).  As for partitioned tables and partition-aligned indexes, I&#8217;ve never done anything special to account for the fact that they&#8217;re partitioned.  As a matter of fact, all the examples I mentioned above were indeed partitioned tables and partition-aligned indexes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oshik</title>
		<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/comment-page-1/#comment-2280</link>
		<dc:creator>Oshik</dc:creator>
		<pubDate>Mon, 16 Nov 2009 13:50:45 +0000</pubDate>
		<guid isPermaLink="false">http://timlaqua.com/?p=250#comment-2280</guid>
		<description>hi TIM,
how the stored procedure Utility_EstimateClusteredIndexSize know how muth indexes i have in specific table?
how it&#039;s know to calculate table with six indexes(one clustered and five nonclustered index)
what about partition table?
Thanks,
Oshik.</description>
		<content:encoded><![CDATA[<p>hi TIM,<br />
how the stored procedure Utility_EstimateClusteredIndexSize know how muth indexes i have in specific table?<br />
how it&#8217;s know to calculate table with six indexes(one clustered and five nonclustered index)<br />
what about partition table?<br />
Thanks,<br />
Oshik.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/comment-page-1/#comment-2236</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Thu, 12 Nov 2009 19:30:52 +0000</pubDate>
		<guid isPermaLink="false">http://timlaqua.com/?p=250#comment-2236</guid>
		<description>Sure, if you can let me know what parameters you&#039;re passing to the procedure, I can take a look and try to figure out why it&#039;s not working as expected</description>
		<content:encoded><![CDATA[<p>Sure, if you can let me know what parameters you&#8217;re passing to the procedure, I can take a look and try to figure out why it&#8217;s not working as expected</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vinayak</title>
		<link>http://timlaqua.com/2009/10/estimating-the-size-of-a-table-in-sql-server-2008/comment-page-1/#comment-2235</link>
		<dc:creator>vinayak</dc:creator>
		<pubDate>Thu, 12 Nov 2009 11:02:40 +0000</pubDate>
		<guid isPermaLink="false">http://timlaqua.com/?p=250#comment-2235</guid>
		<description>Hi,

i tried to run this. Its giving so many errors.first i executed TableColumnDefinition and theni executed the procedure.its thorowing so many exceptions. can u pls tel the way to run this?

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>i tried to run this. Its giving so many errors.first i executed TableColumnDefinition and theni executed the procedure.its thorowing so many exceptions. can u pls tel the way to run this?</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

