Question

It is written everywhere that data in SQL Server is written in pages of 8K (8192 B) each with 8060 bytes for data and the rest is overhead (system info).

Though, the recent article [1] gives code example illustrating, as I understood, that 8078 bytes of data fit into a page.

What do I miss in understanding 8,060 B per per page?

I verified the code on x86 SQL Server 2008 R2...


Update:

Did I see an answer telling about follow-ups to [1]? I pity that I did not mark that as helpful (to me) and comment immediately... I just wanted to investigate more myself before responding...


Update2:

I posted subquestion [2]

[1]
How table design can impact your SQL Server performance?
http://sqlserver-training.com/how-table-design-can-impact-your-sql-server-performance/-

[2]
How to come to limits of 8060 bytes per row and 8000 per (varchar, nvarchar)?
How do you get to limits of 8060 bytes per row and 8000 per (varchar, nvarchar) value?

Was it helpful?

Solution

Long answer short, the limit is 8060 bytes per row, but 8096 bytes per page. The rows in the article you linked have a row size of ~4000 bytes, so they are well under the limit per row. However, that does not answer the question of how many such rows fit on a page.

See "Estimating the size of a heap" in Books Online:

http://msdn.microsoft.com/en-us/library/ms189124.aspx

If you do the calculation for the tables in the article, you'll see that the first table has a physical row size of 4048 bytes, which is exaclty half the 8096 limit for a page.

OTHER TIPS

  • The maximum row size is 8060 bytes
  • In this case, there are two rows each of 4039 bytes
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top