开发者

8078 bytes in 8060 B datapage (SQL Server)?

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://s开发者_运维问答qlserver-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?


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.


  • The maximum row size is 8060 bytes
  • In this case, there are two rows each of 4039 bytes
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜