Solved

# SQL Sizing

Posted on 2004-09-16
292 Views
ADE4SW  CHAR     (1)      NOT NULL ) ON [PRIMARY]

please break it down step by step before arriving to the answer with the fomular use for each step
put into configuration that the fill factor is 100%

Thanks
0
Question by:gbemisola04082004
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 5
• 2

LVL 43

Expert Comment

ID: 12079683

1.      Specify the number of rows present in the table:
Number of rows in the table =3000000 -- Num_Rows
2.      If there are fixed-length and variable-length columns in the table definition, calculate the space that each of these groups of columns occupies within the data row. The size of a column depends on the data type and length specification. For more information, see Data Types.
Number of columns = 9 -- Num_Cols
Sum of bytes in all fixed-length columns =43 -- Fixed_Data_Size
Number of variable-length columns =2 -- Num_Variable_Cols
Maximum size of all variable-length columns = 216 -- Max_Var_Size
3.      If there are fixed-length columns in the table, a portion of the row, known as the null bitmap, is reserved to manage column nullability. Calculate its size:
Null Bitmap (Null_Bitmap) = 2 + (( Num_Cols + 7) / 8 )
Only the integer portion of the above expression should be used; discard any remainder.
4.      If there are variable-length columns in the table, determine how much space is used to store the columns within the row:
Total size of variable-length columns (Variable_Data_Size) = 2 + (Num_Variable_Cols x 2) + Max_Var_Size
(Variable_Data_Size) = 2+2x2 +216=222
If there are no variable-length columns, set Variable_Data_Size to 0.
This formula assumes that all variable-length columns are 100 percent full. If you anticipate that a lower percentage of the variable-length column storage space will be used, you can adjust the result by that percentage to yield a more accurate estimate of the overall table size.
5.      Calculate the row size:
Total row size (Row_Size) = Fixed_Data_Size + Variable_Data_Size + Null_Bitmap +4
(Row_Size) = 43                      +  222                      + 0                 +4=269
The final value of 4 represents the data row header.
6.      Calculate the number of rows per page (8096 free bytes per page):
Number of rows per page (Rows_Per_Page) = ( 8096 ) / (Row_Size + 2)
(Rows_Per_Page) = ( 8096 ) /(269 +2)=30
Because rows do not span pages, the number of rows per page should be rounded down to the nearest whole row.
7.      If a clustered index is to be created on the table, calculate the number of reserved free rows per page, based on the fill factor specified. For more information, see Fill Factor. If no clustered index is to be created, specify Fill_Factor as 100.
Number of free rows per page (Free_Rows_Per_Page) = 8096 x ((100 - Fill_Factor) / 100) / (Row_Size + 2)
(Free_Rows_Per_Page)=8096x ((100-100)/100)/(30+2)=3
The fill factor used in the calculation is an integer value rather than a percentage.
Because rows do not span pages, the number of rows per page should be rounded down to the nearest whole row. As the fill factor grows, more data will be stored on each page and there will be fewer pages.
8.      Calculate the number of pages required to store all the rows:
Number of pages (Num_Pages) = Num_Rows / (Rows_Per_Page - Free_Rows_Per_Page)
(Num_Pages) =3000000/(30-3)= 111111

The number of pages estimated should be rounded up to the nearest whole page.
9.      Calculate the amount of space required to store the data in a table (8192 total bytes per page):
Table size (bytes) = 8192 x Num_Pages
Bytes =8192x111111=910222222Bytes =88889 kB=87MB
step-by-step Estimating the Size of a Table
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_02_92k3.asp
0

LVL 43

Expert Comment

ID: 12079698
my post above can have errors please check\review\recalculate to be sure for right result
0

Author Comment

ID: 12096483
Eugene , thank for the result .I need your clrification on  (Number 7  the free row per page )the row _size on the below formula should be (269+2)

but in your calculation you make it (30+2)

Number of free rows per page (Free_Rows_Per_Page) = 8096 x ((100 - Fill_Factor) / 100) / (Row_Size + 2)
(Free_Rows_Per_Page)=8096x ((100-100)/100)/(30+2)=3

i think  the formular for free_rows_per_page, the  row _size should be  (269 +2 ) not (30 +2) according to the calculation below for row_size

Calculate the row size:
Total row size (Row_Size) = Fixed_Data_Size + Variable_Data_Size + Null_Bitmap +4
(Row_Size) = 43                      +  222                      + 0                 +4=269

(Free_Rows_Per_Page)=8096x ((100-100)/100)/(30+2)=3

I will appriciate if you can let me know
0

LVL 43

Expert Comment

ID: 12097747
I'r right
looks like typo from me
:'-(

30 is rows_per_page but Row-Size

Number of rows per page (Rows_Per_Page) = ( 8096 ) / (Row_Size + 2)
(Rows_Per_Page) = ( 8096 ) /(269 +2)=30
0

LVL 43

Expert Comment

ID: 12097785
num_pages=100000
Table size (bytes) = 8192 x Num_Pages
Bytes =8192x100000=819200000Bytes =800000 kB=781.25 MB ?
Anyway verify

0

Author Comment

ID: 12100793
how do you calculat e your num_pages to be 100000

do you round it up or what

0

LVL 43

Accepted Solution

Eugene Z earned 500 total points
ID: 12117128
yes rounded see #8

8.     Calculate the number of pages required to store all the rows:
Number of pages (Num_Pages) = Num_Rows / (Rows_Per_Page - Free_Rows_Per_Page)

The number of pages estimated should be rounded up to the nearest whole page.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
###### Suggested Courses
Course of the Month5 days, 20 hours left to enroll