硬盘空间术语:unallocated, unused and reserved

简介:

通过standard reports查看Disk Usage,选中Database,右击,选择Reports->Standard Reports->Disk Space Usage,截图如下

在Disk Usage 报表中,Data Files Space Usage分为4部分:Index , Data,Unallocated 和 Unused。

  • Index 是Index 结构实际占用的space
  • Data 是table objects实际占用的space
  • Unused 是已经allocate 给db objects(index or table),但是objects未实际占用的space
  • Reserved 是table objects实际占用的space +Index Objects所占用的space + Unused space,可以理解为已经 allocate 给数据库objects使用的space。
  • Unallocated是没有allocate给任何db object的space,这部分space不属于任意object,没有被任何数据库object使用。如果有object需要space,可以从这部分space中allocate。
  • database file的total size = Reserved Space+Unallocated Space。

Unallocated space是预留的存储空间,在DB运行时,如果有 object 需要空间,那么Sql Server直接将这部分space分配给object,而不用向OS申请额外的disk space。向OS申请额外的disk space会导致data file的grow,由于申请额外的disk space需要耗费一定的时间对space进行初始化,可能会导致transaction timeout,导致transaction失败而rollback。所以,良好的DB Design都会预留足够的disk space,即保持一定量的Unallocated space。

如果Unallocated Space 过大,会导致Disk space exhaust,这时就需要shrink file,以free space。命令dbcc shrinkfile 释放的空间就是Unallocated space,释放之后,这部分空间返回给OS。

 

Unallocated is extents that are not in use. In essence, these extents are maked with bit 1 in GAM page. Any type of grow will produce unallocated extents.

Unused are pages on allocated extents, but thise pages are not yet used by any objects. As soon as an extent is allocated (either as uniform or shared extent), we have 8 reserved pages on that extent. Some pages are used, and some are unused.

 

图片来源于:SQL Server – Understanding ‘sp_spaceused’ Results for Database Size Information

 

推荐文档:Difference between unallocated and unused space

Unallocated space could be returned to the OS when you shrink a file, but the unused space is space that has already been allocated to an object, but just doesn’t yet have any data stored in it.

Unallocated space is the sum of the space used by extents that are not yet allocated to any database objects. So basically it’s the size of the database file(s) minus the sum of the space used by all extents that are assigned to objects be they data,index,GAM,IAM,SGAM,PFS,BCM or DCM pages.

Unused space is the sum of free space available on pages in the data file(s) that have been allocated to an object or objects. Thus running sp_spaceused on a table for instance, the sum of the data and index page space plus the unused space will give you the total space (reserved column in the resultset).

As rows are inserted,updated and deleted in a table then in almost all circumstances there will be some free space on each page. As deletes and updates occur, plus inserts into a table with a clustered index where inserts may not be in clustered index order, then there may well be readjustment of space on the pages e.g. page splits, ghost records etc. Some of this space may be reused but some of it may not, thus as there is transactional activity in your database , the unused space will tend to increase along with the data and index space. This is where defragmenting your indexes can come into play in terms of compacting this unused space and making your data pages and indexes more efficent. You can determine the average freespace on a page for an object using dbcc showcontig.

It is not uncommon to have some 30-50% of the database size as unallocated.

…at database level :

USE AdventureWorks2008R2
GO

EXEC sp_spaceused
GO

Results

First Recordset:

  • database_name: Name of the current database
  • database_size: Size of the current database in megabytes. database_size includes both data and log files
  • unallocated space: Space in the database that has not been reserved for database objects

Second Recordset:

  • reserved: Total amount of space allocated by objects in the database
  • data: Total amount of space used by data
  • index_size: Total amount of space used by indexes
  • unused: Total amount of space reserved for objects in the database, but not yet used

…at table level:

USE AdventureWorks2008R2
GO

EXEC sp_spaceused N'Person.Person'
GO

Results

  • name: Table name for which space usage information was requested
  • rows: Number of rows existing in the table
  • reserved: Total amount of reserved space for table data and indexes
  • data: Amount of space used by table data
  • index_size: Amount of space used by table indexes
  • unused: Total amount of space reserved for table but no yet used
作者悦光阴
本文版权归作者和博客园所有,欢迎转载,但未经作者同意,必须保留此段声明,且在文章页面醒目位置显示原文连接,否则保留追究法律责任的权利。
分类: 数据库管理




本文转自悦光阴博客园博客,原文链接:http://www.cnblogs.com/ljhdo/p/5128259.html,如需转载请自行联系原作者
目录
相关文章
|
Web App开发 开发者
Chrome 插件篇 - 已安装的crx插件源码查看,插件安装位置查看方法
Chrome 插件篇 - 已安装的crx插件源码查看,插件安装位置查看方法
2014 0
Chrome 插件篇 - 已安装的crx插件源码查看,插件安装位置查看方法
|
缓存 搜索推荐 索引
「Mac畅玩鸿蒙与硬件12」鸿蒙UI组件篇2 - Image组件的使用
在鸿蒙应用开发中,Image 组件用于加载和显示图片资源,并提供多种属性来控制图片的显示效果和适配方式。本篇将带你学习如何在鸿蒙应用中加载本地和远程图片、设置图片样式以及实现简单的图片轮播功能。
855 7
「Mac畅玩鸿蒙与硬件12」鸿蒙UI组件篇2 - Image组件的使用
|
人工智能
生成式人工智能认证(GAI认证)官网 - 全国统一认证中文服务平台上线
生成式人工智能(AI)正深刻改变职场规则,但系统化学习相关技术成为难题。近日,由全球知名教育公司培生推出的生成式人工智能认证(GAI认证)中文官网正式上线,为专业人士和学习者提供了权威解决方案。该认证涵盖核心技能、提示工程、伦理合规等内容,助力持证者紧跟技术前沿,在职场中脱颖而出。全国统一认证平台提供便捷报名与在线考试服务,考后快速出成绩并颁发证书。行动起来,开启AI职业新篇章!
|
机器学习/深度学习 计算机视觉
一文详解残差网络
残差网络(ResNet)源于2016年的论文《Deep Residual Learning for Image Recognition》,旨在解决深层网络中的梯度消失和爆炸问题。通过引入残差块,即在网络中添加跳跃连接,使得信息可以直接跨过多层传递,从而有效解决了网络加深导致的训练困难。ResNet不仅显著提高了模型性能,还促进了深度学习领域的发展。
2851 3
|
机器学习/深度学习 自然语言处理 语音技术
ChatTTS大模型在广播电视领域的应用实例
本文介绍了基于ChatTTS大模型的文字转语音工具,该工具结合现代文本处理和语音合成技术,提供高效的音频生成解决方案。文章详细描述了工具的主要功能,包括文本输入、语音选择、语速调整等,并探讨了其在广播电视行业的应用前景,如新闻播报、广告制作和教育培训等领域。未来,该工具将集成更多高级功能,以满足行业需求。
522 9
|
存储 人工智能 算法
云工开物合作动态丨阿里云人工智能通识教学合作
阿里云人工智能通识教学合作为高校提供全面支持,包括视频理论课、动手实践课、AI实践平台、教学管理平台、专属算力资源及线下workshop。
|
存储 索引 Python
从中序与后序遍历序列构造二叉树
【10月更文挑战第13天】这段内容介绍了一种基于中序和后序遍历序列构建二叉树的方法。通过识别后序遍历中的根节点,并利用中序遍历划分左右子树,进而递归构建整棵树。文中提供了具体示例及Python代码实现,并分析了该方法的时间与空间复杂度。
637 0
|
域名解析 缓存 网络协议
理解DNS的重要性与影响
【8月更文挑战第24天】
708 0
|
数据挖掘 API 网络安全
如何使用Google Compute Engine入门指南快速创建和配置您的云虚拟机实例
Google Compute Engine(GCE)是 Google Cloud Platform(GCP)的一部分,它为用户提供了高度可扩展的虚拟机实例,用于运行各种工作负载,从简单的网站托管到复杂的数据分析。本文将引导您完成使用 Google Compute Engine 的入门过程,以便您可以轻松开始使用这一强大的云计算平台。
1967 0
|
安全 小程序 Java
基于SpringBoot养老院管理系统设计和实现(源码+LW+调试文档+讲解等)
基于SpringBoot养老院管理系统设计和实现(源码+LW+调试文档+讲解等)