Nvarchar 或 varchar 哪个更好地使用乘以 2 或四舍五入的全数? [英] Nvarchar or varchar what is better use multiply of 2 or rounded full numbers?

查看:31
本文介绍了Nvarchar 或 varchar 哪个更好地使用乘以 2 或四舍五入的全数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是在 SQL 中生成列时使用什么更好.nvarchar (varchar) 的大小应该乘以 2 (32, 64, 128) 还是没关系,我们可以使用完整的数字示例 '100', '50' ?

My question is what is better to use in generating columns in SQL. Should the size of nvarchar (varchar) be multiply of 2 (32, 64, 128) or it's doesn't matter and we can use fully numbers example '100', '50' ?

非常感谢您的回答

向大家问好

推荐答案

没有任何区别.使用适合您数据的大小.

Doesn't make any difference. Use the size appropiate for your data.

例如 SQL Server,如果您查看 记录剖析 你会看到你的大小转换成记录偏移量,这些偏移量取决于表中的前一条记录、空值和其他因素,特别是行压缩和页面压缩考虑在内.到该字段被访问时,与原始声明大小关系的任何相似之处,相对于 2 的幂或 10 的幂,早已不复存在.查询执行堆栈上的各种元素,如连接运算符或排序运算符或其他任何东西,也不会从 2 大小的幂中受益(我没有证明"链接,但如果你相信我的话就可以了......).在将数据编组回客户端时,TDS 协议也没有.我也认为客户没有什么好处.

For instance SQL Server, if you look at the Anatomy of a Record you'll see that your size translates into record offsets that are dependent on the previous record in the table, null values and other factors, specially with row compression and page compression taken into account. By the time the field is accessed, any resemblance with the original declare size relation, vis-a-vis powers of 2 or powers of 10, is long gone. Also various elements higher on a query execution stack like join operators or sort operators or whatever, also would no benefit from powers of 2 sizes (I have no 'proof' linkes, but is OK if you take my word for it...). Neither does the TDS protocol when marshaling data back to client. And I see little benefit in the client too.

这篇关于Nvarchar 或 varchar 哪个更好地使用乘以 2 或四舍五入的全数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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