8078 bytes in 8060 B datapage (SQL Server)?
Asked Answered
G

2

4

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?

Gallnut answered 23/9, 2010 at 13:16 Comment(1)
the way this question is written and formatted makes it hard to readConcenter
P
4

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.

Parcheesi answered 23/9, 2010 at 13:46 Comment(1)
Thanks, I upvoted your answer. Plz see my question (Update 2 in main post)Proportion
G
2
  • The maximum row size is 8060 bytes
  • In this case, there are two rows each of 4039 bytes
Geometrician answered 23/9, 2010 at 13:48 Comment(2)
Thanks, I upvoted your answer. Plz see my question (Update 2 in mymain post)Proportion
@vgv8: I have answered your other questionGeometrician

© 2022 - 2024 — McMap. All rights reserved.