Monday, December 27, 2010

Table Size Estimation!!!


Someone says Table is the core object of a database, I would say its the heart of a SQL Server.

Today, I come up with one interesting observation regarding the table size estimation.
The requirement is to design a table to store Customer information for which i have to find the estimated size of the table for 1000000 records.

Table: CustomerInfo

Column Name
Datatype
ID
INT
FIRSTNAME
VARCHAR(30)
LASTNAME
VARCHAR(30)
ADDRESS
VARCHAR(50)
CITY
VARCHAR(15)
STATE
CHAR(2)
ZIP
CHAR(10)

Heres the procedure to estimate the size:

1. Find size of the row :
4+30+30+50+15+2+10 = 141 bytes

2. Divide 8096 by result above:
8096/141 = 57 (# of rows that fit on page)

3. Assuming 1000000 is the record count expected, divide the count with step 2 results:
1000000/57 = 17543.8 ~ 17544 (# of pages)

4. Multiplying # of pages with 8192
17544 * 8192 = 143720448 bytes = 137 MB


And thats how we estimate the size of the table!!!

No comments:

Post a Comment