The following example calculates the size (in 2K pages) of the data and clustered index for a table containing:
Follow these steps:
4 | (Overhead) |
+ 100 | Sum of bytes in all fixed-length columns |
+ 50 | Sum of bytes in all variable-length columns |
___ | |
154 | Subtotal |
154 | Subtotal |
+ 1 | (Subtotal / 256) 1 (Overhead) |
+ 3 | Number of variable-length columns 1 |
+ 2 | (Overhead) |
___ | |
160 | Data row size |
2016/160 = 12 Data rows per page
9,000,000/12 = 750,000 Data pages
5 | Overhead |
+ 4 | Sum of bytes in the fixed-length index keys |
___ | |
9 | Clustered index row size |
(2016 / 9) - 2 = 222 Clustered index rows per page
750,000 / 222 = 3378 Index pages (Level 0)
3378 / 222 = 15 Index pages (Level 1)
15 / 222 = 1 Index page (Level 2)
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 |