Showing posts with label space. Show all posts
Showing posts with label space. Show all posts

Thursday, February 16, 2012

Calculating table size

I have a BIG database with 8 tables growing rapidly. I would like to estimate the size of a row in disk space so I can predict how big my bd will grow in time. I know the math to calculate this but I'm look for a tool to automate this task. A tool that takes into accout calculating index size aside from table size.

I would really apreciate any help on this.

regards

? Since you already have the tables, with rows of real data, I think you can do better than an estimation tool. Take the current table size: EXEC sp_spaceused 'yourTable' ... then get the number of rows: SELECT COUNT(*) FROM yourTable ... and divide. This will give you a much more realistic estimate than any tool can. -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <Jorge González@.discussions.microsoft.com> wrote in message news:acc81bad-c554-4d2b-8289-fb1482786568@.discussions.microsoft.com... I have a BIG database with 8 tables growing rapidly. I would like to estimate the size of a row in disk space so I can predict how big my bd will grow in time. I know the math to calculate this but I'm look for a tool to automate this task. A tool that takes into accout calculating index size aside from table size. I would really apreciate any help on this. regards|||

The Disk Usage report in SQL Server Management Studio shows you the current size of your database breaking down the statistics by table, row size, index, partitions, etc.

I'm putting together a blog series on Management Studio reports. In the first post, I put together a 2 minute demo of how to view the reports and export them to Microsoft Excel 2007.

http://blogs.msdn.com/sqlrem/archive/2006/05/16/SSMS_Reports_1.aspx

-Paul

|||? Hi Paul, I'll check out your webcast, but I'd just like to give a bit of feedback on the reports themselves. Although I really love the look and feel and depth of content of these reports, I find that they're too heavy to run on a busy production server -- especially one with a lot of databases and/or a lot of tables. Would it be possible to modify the reports for a future release such that the drill-down data is "lazy loaded" on demand? This would make the reports a lot more useable for enterprise scenarios. -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <Paul Mestemaker - MSFT@.discussions.microsoft..com> wrote in message news:7fb4862e-7192-496e-b484-e1547a88728d@.discussions.microsoft.com... The Disk Usage report in SQL Server Management Studio shows you the current size of your database breaking down the statistics by table, row size, index, partitions, etc. I'm putting together a blog series on Management Studio reports. In the first post, I put together a 2 minute demo of how to view the reports and export them to Microsoft Excel 2007. http://blogs.msdn.com/sqlrem/archive/2006/05/16/SSMS_Reports_1.aspx -Paul|||

I apologize for the delay in response, I have not setup the alerts properly.

We are somewhat limited in how we can load data into the ReportViewer control in Management Studio. There are two ways the control supports an interactive experience.

Drill-in
This is what we do today. We load in all of the data we need to render the report and show/hide information giving a simulated interactive experience.
|||

Hi Jorge,

You can try the following script on SQL 2000 / 2005

CREATE TABLE #SpaceUsed (name sysname,rows bigint,reserved sysname,data sysname,index_size sysname,unused sysname)

DECLARE @.Counter int
DECLARE @.Max int
DECLARE @.Table sysname

SELECT name, IDENTITY(int,1,1) ROWID
INTO #TableCollection
FROM sysobjects
WHERE xtype = 'U'
ORDER BY lower(name)

SET @.Counter = 1
SET @.Max = (SELECT Max(ROWID) FROM #TableCollection)

WHILE (@.Counter <= @.Max)
BEGIN
SET @.Table = (SELECT name FROM #TableCollection WHERE ROWID = @.Counter)
INSERT INTO #SpaceUsed
EXECUTE sp_spaceused @.Table
SET @.Counter = @.Counter + 1
END

SELECT * FROM #SpaceUsed

DROP TABLE #TableCollection
DROP TABLE #SpaceUsed

Regards

Calculating table size

I have a BIG database with 8 tables growing rapidly. I would like to estimate the size of a row in disk space so I can predict how big my bd will grow in time. I know the math to calculate this but I'm look for a tool to automate this task. A tool that takes into accout calculating index size aside from table size.

I would really apreciate any help on this.

regards

? Since you already have the tables, with rows of real data, I think you can do better than an estimation tool. Take the current table size: EXEC sp_spaceused 'yourTable' ... then get the number of rows: SELECT COUNT(*) FROM yourTable ... and divide. This will give you a much more realistic estimate than any tool can. -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <Jorge González@.discussions.microsoft.com> wrote in message news:acc81bad-c554-4d2b-8289-fb1482786568@.discussions.microsoft.com... I have a BIG database with 8 tables growing rapidly. I would like to estimate the size of a row in disk space so I can predict how big my bd will grow in time. I know the math to calculate this but I'm look for a tool to automate this task. A tool that takes into accout calculating index size aside from table size. I would really apreciate any help on this. regards|||

The Disk Usage report in SQL Server Management Studio shows you the current size of your database breaking down the statistics by table, row size, index, partitions, etc.

I'm putting together a blog series on Management Studio reports. In the first post, I put together a 2 minute demo of how to view the reports and export them to Microsoft Excel 2007.

http://blogs.msdn.com/sqlrem/archive/2006/05/16/SSMS_Reports_1.aspx

-Paul

|||? Hi Paul, I'll check out your webcast, but I'd just like to give a bit of feedback on the reports themselves. Although I really love the look and feel and depth of content of these reports, I find that they're too heavy to run on a busy production server -- especially one with a lot of databases and/or a lot of tables. Would it be possible to modify the reports for a future release such that the drill-down data is "lazy loaded" on demand? This would make the reports a lot more useable for enterprise scenarios. -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <Paul Mestemaker - MSFT@.discussions.microsoft..com> wrote in message news:7fb4862e-7192-496e-b484-e1547a88728d@.discussions.microsoft.com... The Disk Usage report in SQL Server Management Studio shows you the current size of your database breaking down the statistics by table, row size, index, partitions, etc. I'm putting together a blog series on Management Studio reports. In the first post, I put together a 2 minute demo of how to view the reports and export them to Microsoft Excel 2007. http://blogs.msdn.com/sqlrem/archive/2006/05/16/SSMS_Reports_1.aspx -Paul|||

I apologize for the delay in response, I have not setup the alerts properly.

We are somewhat limited in how we can load data into the ReportViewer control in Management Studio. There are two ways the control supports an interactive experience.

Drill-in
This is what we do today. We load in all of the data we need to render the report and show/hide information giving a simulated interactive experience.
|||

Hi Jorge,

You can try the following script on SQL 2000 / 2005

CREATE TABLE #SpaceUsed (name sysname,rows bigint,reserved sysname,data sysname,index_size sysname,unused sysname)

DECLARE @.Counter int
DECLARE @.Max int
DECLARE @.Table sysname

SELECT name, IDENTITY(int,1,1) ROWID
INTO #TableCollection
FROM sysobjects
WHERE xtype = 'U'
ORDER BY lower(name)

SET @.Counter = 1
SET @.Max = (SELECT Max(ROWID) FROM #TableCollection)

WHILE (@.Counter <= @.Max)
BEGIN
SET @.Table = (SELECT name FROM #TableCollection WHERE ROWID = @.Counter)
INSERT INTO #SpaceUsed
EXECUTE sp_spaceused @.Table
SET @.Counter = @.Counter + 1
END

SELECT * FROM #SpaceUsed

DROP TABLE #TableCollection
DROP TABLE #SpaceUsed

Regards

Tuesday, February 14, 2012

Calculating space

Hi
Problem - I want to create a query that give me this results
Table, Column , Datatype, Rowcount, Size.
I have a question though, I've read in BOL about how to calculate space
based on variable and fixed lengths of datatypes. What I am not sure about i
s
how to sql allocate space.
Let's say I have a nvarchar(10) column, this is variable length and size
will be the amount of characters entered times two.
For the fixed lenght nchar(n) BOL specify the storage size will be two times
n bytes and one time when working with char.
However in nchar or char, does this mean the size is used even if the actual
char in the field is only 1 out of the 10 characters ?
Char doesn't specify "amount of characters entered" like varchar.
Can someone please help me out with info or a link.
Thanks in advanceFor character type columns the number of bytes they take up on disk is
calculated as follows:
2 bytes if it is variable length (to store the offset in the row)
+ (length for fixed length column or actual data length for variable length
column) * (2 if n(var)char or 1 if (var)char)
You can get the values for the actual number of bytes a column takes up in a
row with the DATALENGTH function. (The result doesn't include the 2 bytes to
store the variable length offset, as that is contributed to row overhead
rather than the column length).
Jacco Schalkwijk
SQL Server MVP
"Mal .mullerjannie@.hotmail.com>" <<removethis> wrote in message
news:80A0E3A9-EA58-49A7-B802-A1FDEA70D092@.microsoft.com...
> Hi
> Problem - I want to create a query that give me this results
> Table, Column , Datatype, Rowcount, Size.
> I have a question though, I've read in BOL about how to calculate space
> based on variable and fixed lengths of datatypes. What I am not sure about
> is
> how to sql allocate space.
> Let's say I have a nvarchar(10) column, this is variable length and size
> will be the amount of characters entered times two.
> For the fixed lenght nchar(n) BOL specify the storage size will be two
> times
> n bytes and one time when working with char.
> However in nchar or char, does this mean the size is used even if the
> actual
> char in the field is only 1 out of the 10 characters ?
> Char doesn't specify "amount of characters entered" like varchar.
> Can someone please help me out with info or a link.
> Thanks in advance
>|||Always specify the size, never leave it to the default. With Char and NChar
datatypes the value stored in the database is always the full size that you
specified since it will padd with spaces. For instance if you have a
CHAR(10) and enter 'xyz' it will still be 10 bytes long and converts to 'xyz
'.
Andrew J. Kelly SQL MVP
"Mal .mullerjannie@.hotmail.com>" <<removethis> wrote in message
news:80A0E3A9-EA58-49A7-B802-A1FDEA70D092@.microsoft.com...
> Hi
> Problem - I want to create a query that give me this results
> Table, Column , Datatype, Rowcount, Size.
> I have a question though, I've read in BOL about how to calculate space
> based on variable and fixed lengths of datatypes. What I am not sure about
> is
> how to sql allocate space.
> Let's say I have a nvarchar(10) column, this is variable length and size
> will be the amount of characters entered times two.
> For the fixed lenght nchar(n) BOL specify the storage size will be two
> times
> n bytes and one time when working with char.
> However in nchar or char, does this mean the size is used even if the
> actual
> char in the field is only 1 out of the 10 characters ?
> Char doesn't specify "amount of characters entered" like varchar.
> Can someone please help me out with info or a link.
> Thanks in advance
>