SQL Server 如何保留存储?以及如何推翻它?
我试图了解 SQL Server 如何分配和保留空间。
运行了“表设计如何影响 SQL Server 性能?”一文中的示例。 [1],我收到了与文章[1.1]中的结果不同的结果[我的1.1]。
为什么?
为什么在一种情况下会保留/分配过多的空间([1]中的所有情况),但在另一种情况下[My 1.1]却没有?
(请注意,在 [1] 中,两种情况下都保留了过多的空间,但在我的计算机上仅在其中一种情况下保留了空间)
SQL Server 是如何分配和保留空间的?
我该如何控制/管理它?
[1] ======
表设计如何影响 SQL Server 性能?
http://sqlserver-training.com/表设计如何影响您的 sql 服务器性能
[我的 1.1]
我的结果从[1.1]下面的
name rows reserved data index_size unused
---------------------------------- ----- --------- -------- ----------- ---------
Fixed_Lenght_Row_Table_Optimised 10000 40008 KB 40000 KB 8 KB 0 KB
[ 1]转移 结果 [1] 从我上面的
name rows reserved data index_size unused
---------------------------------- ----- --------- -------- ----------- ---------
Fixed_Lenght_Row_Table_Optimised 10000 40072 KB 40000 KB 8 KB 64 KB
[1.2] 转移
[1] 的结果与我的一致
name rows reserved data index_size unused
---------------------------------- ----- --------- -------- ----------- ---------
Fixed_Lenght_Row_Table_Non_Optimised 10000 80072 KB 80000 KB 8 KB 64 KB
I am trying to understnad how SQL Server allocates and reserves space.
Having run the examples from the article "How table design can impact your SQL Server performance?" [1], I received the results [My 1.1] diverting from those in article [1.1].
Why?
Why in one case the excessive space is reserved/allocated (all cases in [1]) but not in another [My 1.1]?
(Note that in [1] in both cases the excessive space is reserved, though on my computer only in one of cases)
How is space allocated, reserved by SQL Server?
And how can I control/manage it?
[1] ======
How table design can impact your SQL Server performance?
http://sqlserver-training.com/how-table-design-can-impact-your-sql-server-performance
[My 1.1]
My results diverting from [1] below
name rows reserved data index_size unused
---------------------------------- ----- --------- -------- ----------- ---------
Fixed_Lenght_Row_Table_Optimised 10000 40008 KB 40000 KB 8 KB 0 KB
[1.1]
Results in [1] diverting from mine above
name rows reserved data index_size unused
---------------------------------- ----- --------- -------- ----------- ---------
Fixed_Lenght_Row_Table_Optimised 10000 40072 KB 40000 KB 8 KB 64 KB
[1.2]
Results from [1] coinciding with mine
name rows reserved data index_size unused
---------------------------------- ----- --------- -------- ----------- ---------
Fixed_Lenght_Row_Table_Non_Optimised 10000 80072 KB 80000 KB 8 KB 64 KB
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
链接中的文章充其量是可疑的。不指定要使用的 SQL Server 版本以及启用/禁用的各种选项。从 SQL Server 2005 开始,对于超出 8K 限制的列,存在行小 lob 存储(请参阅 表和索引组织),有默认的行内与行外选项(请参阅sp_tableoption),并且有许多压缩选项(行级、页面级、Unicode)。
为了获得准确的信息,我会坚持使用官方产品文档,从 规划和架构 (数据库引擎)。为了更容易理解,请购买一本成熟的书籍,例如 Microsoft SQL Server 2008 Internals 或Microsoft SQL Server 2005 内部:存储引擎。
The article in the link is dubious at best. Does not specify what SQL Server version to use, and what are the various options enabled/disabled. Since SQL Server 2005 there is row small-lob storage for columns over spilling the 8K limit (see Table and Index Organization), there are default in-row vs. out-of-row options (see sp_tableoption) and there are many compression options (row-level, page-level, Unicode).
For accurate information I would stick to the official product documentation, starting from Planning and Architecture (Database Engine). For a more digestible read, buy one of the well established books, like Microsoft SQL Server 2008 Internals or Inside Microsoft SQL Server 2005: The Storage Engine.
这是有道理的:您有 64k 未使用空间。您经常会看到保留空间中的细微差别,就像这样,
我也会使用第二个参数以这种方式运行它。这可能没有什么区别
然后从 sp_spaceused
最后,您的表是否会包含 4000 字节以上的行?如果您想覆盖以优化,我想说您还为时过早......只需使设计的实现正确即可(它们是单独的步骤)
It makes sense: you have 64k unused space. You'll often see minor differences in reserved space like this
I'd also run it this way too with the 2nd parameter. It may make no difference
And then from sp_spaceused
Finally, will you have tables that will have 4000 byte+ rows? If you want to override to optimise, I'd say you're premature... just make your implementation of the design is correct (they are separate steps)