The following example calculates the size, in 2K pages, of the data and clustered index for a table containing:
The five steps previously discussed were used to ascertain the table size.
Calculate the data row size.
4 Overhead
+ 100 Sum of bytes in all fixed-length columns
+ 50 Sum of bytes in all variable-length columns
———--
154 Subtotal
+ 1 (Subtotal / 256) + 1 (Overhead)
+ 3 Number of variable-length columns + 1
+ 2 (Overhead)
———--
160 Data row size
Calculate the number of data pages.
2,016/160 = 12 data rows per page
9,000,000/12 = 750,000 data pages
Calculate the size of clustered index rows.
5 Overhead
+ 4 Sum of bytes in the fixed-length index keys
———--
9 Clustered index row size
Calculate the number of clustered index pages.
(2,016/9) — 2 = 222 clustered index rows per page
750,000/222 = 3,378 index pages (level 0)
3,378/222 = 15 index pages (level 1)
15/222 = 1 index page (level 2)
Calculate the total number of pages.
Totals | Pages | Rows |
Level 2 (root) | 1 | 15 |
Level 1 | 15 | 3,378 |
Level 0 | 3,378 | 750,000 |
Data | 750,000 | 9,000,000 |
——— | ||
Total number of 2K pages | 753,394 |