Hobt_id和Partition_id这两个字段的值是相同的,每一个分区都有一个ID值,这个值是Partition_id。在每一个partition中,最多有三个allocation unit,type分别是 in_row, Lob, row_overflow。每一个allocation unit 都含有很多data page,存储data和index。
Allocation Unit 可以理解为partition的单一data pages的集合。
Each parition can have three types of rows, each stored on its own set of pages.
These types are called in-row data pages, row-overflow data pages and LOB data pages.
A set of pages of one particular type for one particular partition is called an allocation unit.
Each heap or index on each partition can have as many as three allocation units.
示例图
Sql server 提供两个视图用于查看 allocation unit。
1,sys.allocation_units
Contains a row for each allocation unit in the database.
Column name |
Data type |
Description |
---|---|---|
allocation_unit_id |
bigint |
ID of the allocation unit. Is unique within a database. |
type |
tinyint |
Type of allocation unit: 0 = Dropped 1 = In-row data (all data types, except LOB data types) 2 = Large object (LOB) data (text, ntext, image, xml, large value types, and CLR user-defined types) 3 = Row-overflow data |
type_desc |
nvarchar(60) |
Description of the allocation unit type:
|
container_id |
bigint |
ID of the storage container associated with the allocation unit. If type = 1 or 3, container_id = sys.partitions.hobt_id. If type is 2, then container_id = sys.partitions.partition_id. 0 = Allocation unit marked for deferred drop |
data_space_id |
int |
ID of the filegroup in which this allocation unit resides. |
total_pages |
bigint |
Total number of pages allocated or reserved by this allocation unit. |
used_pages |
bigint |
Number of total pages actually in use. |
data_pages |
bigint |
Number of used pages that have:
Value returned excludes internal index pages and allocation-management pages. |
When you drop or rebuild large indexes, or drop or truncate large tables, the Database Engine defers the actual page deallocations, and their associated locks, until after the transaction commits. Deferred drop operations do not release allocated space immediately. Therefore, the values returned by sys.allocation_units immediately after dropping or truncating a large object may not reflect the actual disk space available.
2,sys.system_internals_allocation_units
比 sys.allocation_units 多三个column:first page,root page 和 first iam page
sys.system_internals_allocation_units 系统视图保留为仅供 Microsoft SQL Server 内部使用。
参考文档:
https://technet.microsoft.com/zh-cn/library/ms189051(v=sql.105).aspx
https://msdn.microsoft.com/en-us/library/ms189792.aspx