8060 B 数据页 (SQL Server) 中有 8078 字节?
到处都是这样写的,SQL Server 中的数据以 8K (8192 B) 的页写入,每个页有 8060 字节的数据,其余的是开销(系统信息)。
不过,最近的文章 [1] 给出了代码示例,据我了解,8078 字节的数据适合一个页面。
在理解每页 8,060 B 时我错过了什么?
我在 x86 SQL Server 2008 R2 上验证了代码...
更新:
我是否看到了有关 [1] 后续行动的答案?我很遗憾我没有将其标记为有帮助(对我)并立即发表评论...我只是想在回复之前自己进行更多调查...
更新2:
我发布了子问题 [2]
[1]
表设计如何影响 SQL Server 性能?
http://sqlserver-training。 com/how-table-design-can-impact-your-sql-server-performance/-
[2]
如何达到每行 8060 字节和每行 8000 个字节(varchar、nvarchar)的限制?
怎么做您是否达到每行 8060 字节和每个(varchar、nvarchar)值 8000 个字节的限制?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
长答案短,限制是每行 8060 字节,但每页 8096 字节。您链接的文章中的行的行大小约为 4000 字节,因此它们远低于每行的限制。然而,这并没有回答一个页面上可以容纳多少这样的行的问题。
请参阅联机丛书中的“估计堆的大小”:
http://msdn .microsoft.com/en-us/library/ms189124.aspx
如果您对本文中的表进行计算,您将看到第一个表的物理行大小为 4048 字节,这是精确的页面 8096 限制的一半。
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.