Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

The size of a table. (space_used against calculated space). Expand / Collapse
Author
Message
Posted Monday, June 10, 2013 6:42 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, July 27, 2014 4:18 AM
Points: 246, Visits: 1,167
With sp_space_used you get the 'gross' size of a table. (Used_size for data)

Summing all fields with a datalength function also gives a size for a table, offcourse this is without the overhead.

The used_size is about 2 to 3 times the calculated size.

So how can I calculate the size more accurately?

Thanks for your time and attention.
ben brugman



Extra info:
This was calculated for heaps and clusters (90 percent fill rate), both were similar.
No deleted rows.
From 30 to 75 columns for each table, with a lot of NULL's.
Overhead was 3 to 5 bytes for each field.
(180 to 280 bytes of overhead for each row).
Post #1461514
Posted Monday, June 10, 2013 6:46 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Tuesday, January 28, 2014 8:15 AM
Points: 3,068, Visits: 4,639
ben.brugman (6/10/2013)
So how can I calculate the size more accurately?


The actual space used by a table is what sp_spaceused reports.


_____________________________________
Pablo (Paul) Berzukov

Author of Understanding Database Administration available at Amazon and other bookstores.

Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Post #1461516
Posted Monday, June 10, 2013 8:15 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, July 27, 2014 4:18 AM
Points: 246, Visits: 1,167
PaulB-TheOneAndOnly (6/10/2013)
ben.brugman (6/10/2013)
So how can I calculate the size more accurately?


The actual space used by a table is what sp_spaceused reports.


Thanks for your reply, but this does not anwser my question.

The links:
http://msdn.microsoft.com/en-us/library/ms189124.aspx
http://msdn.microsoft.com/en-us/library/ms178085.aspx

Do help, but do not even come close to the reported use using sp_spaceused.

Thanks,
ben
Post #1461576
Posted Monday, June 10, 2013 8:47 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, July 1, 2014 3:20 AM
Points: 196, Visits: 650
Do you mean calculate more accurately the size before actually creating the table?

If so, at least some of inaccuracy may be that you would need to factor in the block size. If your row uses 4.5kb and you expect to have 1,000,000 rows you might have calculated 4.5gb but then because you can only fit one row within an 8k block (4.5 * 2 = too much) you end up using 1,000,000*8k blocks (about 8gb).

For smaller rows I'm not sure why it would be so far out...maybe incorrect calculations?

Indexes is easier to guess (fragmentation)~



Dird // Junior DBA
11g OCA
10.5 newbie
Post #1461594
Posted Monday, June 10, 2013 9:11 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:50 PM
Points: 5,574, Visits: 24,823
ben.brugman (6/10/2013)
With sp_space_used you get the 'gross' size of a table. (Used_size for data)

Summing all fields with a datalength function also gives a size for a table, offcourse this is without the overhead.

The used_size is about 2 to 3 times the calculated size.

So how can I calculate the size more accurately?

Thanks for your time and attention.
ben brugman


This discussion of the subject may be of help to you.

http://msdn.microsoft.com/en-us/library/ms189124.aspx


If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Post #1461611
Posted Monday, June 10, 2013 10:28 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, July 27, 2014 4:18 AM
Points: 246, Visits: 1,167
Dird (6/10/2013)
Do you mean calculate more accurately the size before actually creating the table?


At the moment I am trying to do the calculation on existing tables. This allows me to check the method. This brings understanding and will help to calculate the size of future tables.

Ben
Post #1461662
Posted Monday, June 10, 2013 11:09 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, July 27, 2014 4:18 AM
Points: 246, Visits: 1,167
bitbucket-25253 (6/10/2013)

This discussion of the subject may be of help to you.

http://msdn.microsoft.com/en-us/library/ms189124.aspx


As you can see in the third message in this thread I allready mentioned exactly that link. The referenced page is actually only a very rough guide.

If everything seems to be going well, you have obviously overlooked something.


For me it's not obvious what I am overlooking, hence the question.

Because the large number of NULL's, the calculation on the web page is not very accurate. I'll try to come up with a more accurate calculation. Have to count the actual number of Nulls in the variable record fields, I'll need access to the table for this and at the moment I do not have access.

In that way I can see the amount of overhead (quite a lot) which I am missing.

Ben
Post #1461681
Posted Tuesday, June 11, 2013 7:17 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 8:21 AM
Points: 833, Visits: 2,688
ben.brugman (6/10/2013)

If everything seems to be going well, you have obviously overlooked something.


For me it's not obvious what I am overlooking, hence the question.

Don't mistake the cheeky signature line as a rude comment.




The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Post #1462095
Posted Wednesday, June 12, 2013 10:30 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, July 27, 2014 4:18 AM
Points: 246, Visits: 1,167
Sean Pearce (6/11/2013)
ben.brugman (6/10/2013)

If everything seems to be going well, you have obviously overlooked something.


For me it's not obvious what I am overlooking, hence the question.

Don't mistake the cheeky signature line as a rude comment.


Well I sure missed that one.
(English being my third language, the line was above the name and being technical also means that I tend to take things more literal than 'right' brained people.). I do like the quote though.

thanks,
ben
Post #1462718
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse