你如何达到每行 8060 字节和每个(varchar,nvarchar)值 8000 的限制? [英] How do you get to limits of 8060 bytes per row and 8000 per (varchar, nvarchar) value?

查看:22
本文介绍了你如何达到每行 8060 字节和每个(varchar,nvarchar)值 8000 的限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自我的问题8060 B 数据页中的 8078 个字节(SQL Server)?",其中向我解释了如何在 MS SQL Server 中获得每页 8078 字节的数据.

Comining from my question "8078 bytes in 8060 B datapage (SQL Server)?" where it was explained to me how to derive 8078 bytes of data per page in MS SQL Server.

如果我计算每页用于数据存储(无开销)的字节数,只有一行和一列非索引固定大小类型记录(根据 MSDN 文章 估计堆的大小),然后我得到 8087 字节(每页).

If I calculate the number of bytes per page used for data storage (without overhead) of only one row with one column of non-indexed fixed-size type record (as per the MSDN article Estimating the Size of a Heap), then I come to 8087 bytes (per page).

如何在不购买和研究 1000 多页书籍的情况下达到每行 8060 字节(在我的其他问题的答案中提到)和每行 8000 字节(varchar、nvarchar)的限制?

How do I get to to the limits of 8060 bytes per row (mentioned in my other question's answers) and to 8000 bytes per (varchar, nvarchar) without buying and studying 1000+ page books?

我肯定在存储分配中遗漏了一些东西:管理的块越少,开销越大......

I am certainly missing something in storage allocation: the fewer chunks to manage, the more overhead...

推荐答案

存储引擎内部:记录剖析

这适用于 SQL Server 2005

  • 记录头
    • 4 个字节长
    • 两个字节的记录元数据(记录类型)
    • 记录中向前指向 NULL 位图的两个字节
    • 两个字节用于记录中的列数
    • 记录中每列存储一位的可变字节数,无论该列是否可以为空(这与 SQL Server 2000 不同且更简单,SQL Server 2000 每个可空列只有一位)
    • 这允许在读取 NULL 列时进行优化
    • 两个字节用于可变长度列的计数
    • 每个可变长度列两个字节,给出列值末尾的偏移量版本控制标签

    所以,对于一个字符(8000)

    So, for one char(8000)

    • 4 字节(记录头)<​​/li>
    • 8000 固定长度
    • 3 空位图
    • 2 个字节来计算可变长度
    • 14 时间戳

    但是,如果您有 40 个 varchar(200) 列

    However, if you had 40 varchar(200) columns

    • 4 字节(记录头)<​​/li>
    • 0 固定长度
    • 6 个空位图
    • 2 个字节来计算可变长度
    • 202 x 40 = 8080
    • 14 时间戳

    总计 = 8080 + 4 + 6 + 2 + 14 = 8106.WTF?创建此表时收到警告

    Total = 8080 + 4 + 6 + 2 + 14 = 8106. WTF? You get a warning when you created this table

    我不会太在意:这些信息没有日常实用价值

    I would not get too hung up on it: this information has no practical day to day value

    这篇关于你如何达到每行 8060 字节和每个(varchar,nvarchar)值 8000 的限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆