SQL Exam - Assessing Table Size Issues

I am preparing for the SQL Server exam (70-431). I have a book from Sybex, "SQL Server 2005 - Implementation and Maintenance . " I am a bit confused about estimating table size.

The second chapter explains how to do this:

  • Calculate the size of the string formula: Row_Size = Fixed_Data_Size + Variable_Data_Size + Null_Bitmap + Row_Header.
    • Fixed_Data_Size - the sum of all column sizes of a fixed length (simple sum)
    • Variable_Data_Size = 2 + (num_variable_columns × 2) + max_varchar_size, num_variable_columns- the number of variable-length columns, max_varchar_size- the maximum size of the varchar column
    • null_bitmap = 2 + ((number of columns + 7) ÷ 8) (rounded)
    • Row_headeralways equal 4.
  • Calculation of lines per page by the formula: Rows_Per_Page = 8096 ÷ (Row_Size + 2)(rounded down)
  • Estimating the number of rows in a table. Say the table has 1000 rows.
  • Calculation of the number of pages required: No_Of_Pages = 1,000 / Rows_Per_Page(rounded)
  • Total size: Total_Size = No_Of_Pages * 8,192where 8,192 is the size of one page.

So for me this is very clear. I made one example and checked with the answers in the book that my calculations were correct. But there is one question that bothers me.

Question: we have a table with the following diagram:

Name       Datatype
-------------------
ID         Int
VendorID   Int
BalanceDue Money
DateDue    Datetime

This table is expected to have about 5,000 rows. Question (literally): "How much space does the accounts receivable table take?"

So my answer is simple:

null_bitmap = 2 + ((4+7) / 8) = 3.375 = 3 (rounded)
fixed_datasize =  4 + 4 + 8 + 8 = 24
variable_datasize = 0
row_header = 4 (always)

row_size = 3 + 24 + 0 + 4 = 31

Row_header, 4. Row_header ( )? , , , Row_header , , , Row_header. , - . .

+3
1

: , :

:

    • 4
    • ( )
    • , NULL
+3

Source: https://habr.com/ru/post/1726097/


All Articles