Solved

Please explain how to calculate table size by hand (using the provided example)

Posted on 2006-07-10
14
5,116 Views
Last Modified: 2008-01-09
Hi experts...

here is the example I have for you:

http://www.marcoullis.com/EE_DB/

I am trying to learn how to calculate table size, and to be honest I need a dumbed down explanation. Other explanations I have found on the EE website are too complicated. No need to calculate all the tables provided, just if someone could run through one table calculation on the "Tenants.sql" database, and one on the "Rental_Unit" database that would be real cool.

Specifically:

1. The "tbl_Tenant" table in database "Tenants.sql
2. The "tbl_Rental_Unit" in database "Rental_Unit.sql"

The dbms is MySQL. The ERD's are for two database that form the backend of a content management system for a large rental apartment corporation in Washington DC... its an exercise from my school book. I am not interested in specific dbms handling of table calculation, just the theory behind how to calculate table size. Preferably a step-by-step approach that a norom (backwards moron) like myself could understand.

There are no variable length fields, just fixed length.

The "tbl_Rental_Unit" table employs the use of data blobs for all the columns named "Schema_". These are very large pictures of schematics...

Thats all I have... please help...

-Panos
0
Comment
Question by:marcoullisp
  • 6
  • 3
  • 3
  • +2
14 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 17079304
Hi marcoullisp,
Do you mean table size or record size?

Pete
0
 

Author Comment

by:marcoullisp
ID: 17079335
Table size. I want to be able to estimate/calculate the table size for each of the tables shown in the example, and if you could show by example doing the two I have mentioned, that would help me.

But out of curiosity (please don't laugh) whats the difference between record size and table size?

-Panos
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 17079385
marcoullisp,
Record size is the size of one record and is generally impossible to calculate unless everything is fixed length (which (a) would be very unusual and (b) since you are using BLOBs does not apply to your tables).

Table size is dependent on how much data you have and you generally have to use indirect methods to <estimate>  the size.
I think for MySql you would probably have to export the data to a txt file and see how big that was.  The bit missing from this though is all the dbms overhead involved in storing fields and records which is why it is only an estimate.

Pete
0
 

Author Comment

by:marcoullisp
ID: 17079429
Pete: I want the step-by-step logic/process for calculating the size of a table. I don't want the dbms tips and tricks method... just the theory. Also I am not worried about indexes, TRX logs and such for now. I will create a different ticket on EE for that after I understand this first.

-Panos
0
 

Author Comment

by:marcoullisp
ID: 17079433
... and I want to learn this logic or process by using the two examples I mentioned earlier...

-Panos
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17079438
If you run:

show table status from `schemaName`

This will return:

Name                      
Engine  
Version  
Row_format    
Rows  
Avg_row_length  
Data_length    
Max_data_length  
Index_length  
Data_free  
Auto_increment  
Create_time          
Update_time          
Check_time          
Collation        
Checksum  
Create_options      
Comment                                    

Of these the Data_length is the total size (in bytes) of each table
0
 

Author Comment

by:marcoullisp
ID: 17079456
... guys ... you don't understand ... this DB is still in Visio. Its an example from a book. I don't have the dbms thing hooked up ... there is no such DB in existence right now. Its just a theoretical example, thats all.

What I am looking for is the theory behind how to m-a-n-u-a-l-l-y estimate/calculate the size of a table in a database, using the two examples I cited earlier, namely:

1. The "tbl_Tenant" table in database "Tenants.sql
2. The "tbl_Rental_Unit" in database "Rental_Unit.sql"

You can find the specific example here:

http://www.marcoullis.com/EE_DB/

Thanks,

Panos
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 77

Expert Comment

by:peter57r
ID: 17079568
I can't see that there is any theory involved.

You calculate the space requirements for each field; add them together for the size of one record and multiply by the number of records.
The space requirements for a field in mysql are shown here, amongst other places:
http://info2html.sourceforge.net/cgi-bin/info2html-demo/info2html?(mysql.info.gz)Storage%2520requirements

But as I have already said, where you have a blob there is no 'standard' answer. YOU have to decide how big you think each one will be.  

Pete
0
 
LVL 11

Expert Comment

by:pootle_flump
ID: 17079663
As stated - the table size is the sum of the data stored within it (plus an overhead specific to the RDBMSs method of storage). As such the answer to the size of a table in visio is zero. That table schema could (once realised in a database) have any size - it is dependant on the number of rows and, as Pete says, the size of the rows. Also - I don't know how MySQL handles this but many RDBMSs don't actually store BLOBS but just pointers to the files themselves. As such - the specific RDBMS *does* affect the table size.

I know this isn't that answer you are looking for but I don't believe there is one!

HTH
0
 
LVL 11

Expert Comment

by:pootle_flump
ID: 17079700
Beg your pardon. Just noticed you have the number of rows in the link - I missed that :-)
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17079723
Hi marcoullisp,

This link will give you an idea of how to estimate the sizq of the table

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_02_92k3.asp

Cheers!
0
 

Author Comment

by:marcoullisp
ID: 17084198
aneeshattingal and all:

here are the instructions from the MSDN website. Could any of you walk me through this, step-by-step, on just one table, say this one:

1. The "tbl_Tenant" table in database "Tenants.sql

From this:

http://www.marcoullis.com/EE_DB/

Just walk me through just one. Its not the one with the blobs, and there are no variable length fields in there. I just need to know how to calculate the size of each data field essentially.

-Panos
0
 
LVL 11

Expert Comment

by:pootle_flump
ID: 17086349
Hi Panos

The size of the table is equal to the size of the rows * the number of rows.

The size of a row is the sum of the size of all the fields.

You have a table schema and an excellent link from Pete. If you check the link (you need to copy and paste - the full link is not active) you are given the size in Bytes for each data type.

Have a go. Post what you get and your working. We will help you from there. If you read the terms of use to this site you will see that we cannot do your homework. We are not just being awkward. We can point you in the right direction but you must do the hard work :-)

HTH
0
 

Author Comment

by:marcoullisp
ID: 17095701
From the "tbl_Tenants" table I get that the CHAR (10) fields each have size 10 bytes each (or is it 10 bits each?). There are 7 of them so just those field = 7 x 10 = 70 bits/bytes per row. Now, how do I account for the short fields and the one currency field?

-Panos
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Often, when running a query with joins, the results show up "duplicates", and often, those duplicates can be "eliminated" in the results using DISTINCT, for example. Using DISTINCT is simple: just add it after the SELECT keyword, an…
I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now