原文:[url]http://msdn.microsoft.com/en-us/library/ms190969.aspx[/url]
SQL Server中最基本的存储单元是页(page)。系统给数据库文件(.mdf .ndf)分配的磁盘空间逻辑上被分解为从0..n的多个编号连续的页。磁盘的I/O操作是在页级水平完成的,也就是说,SQL Server每次读或写整个的数据页(data page).
盘区(Extent)是物理上连续的8个页,这样便于有效地管理页,所有的页都存储在盘区。
[size=medium][b]页(Pages)[/b][/size]
在SQL Server中,页的大小为8KB。这意味着1M字节可以有128页。每页有一个96字节的页头(Header),页头用来存储页的系统信息,具体包括:页编号,页类型、该页剩余空闲空间、
[b]下面表列出了SQL Server的数据文件中所用的页的类型[/b]
[table]
| page Type | contents |
| Data |Data rows with all data, except text, ntext, image, nvarchar(max), varchar(max), varbinary(max), and xml data, when text in row is set to ON.|
|Index|Index entries.|
|Text/Image|Large object data types:
* text, ntext, image, nvarchar(max), varchar(max), varbinary(max), and xml data
Variable length columns when the data row exceeds 8 KB:
* varchar, nvarchar, varbinary, and sql_variant |
|Global Allocation Map, Shared Global Allocation Map|Information about whether extents are allocated.|
|Page Free Space|Information about page allocation and free space available on pages.|
|Index Allocation Map|Information about extents used by a table or index per allocation unit.|
|Bulk Changed Map|Information about extents modified by bulk operations since the last BACKUP LOG statement per allocation unit.|
|Differential Changed Map|Information about extents that have changed since the last BACKUP DATABASE statement per allocation unit.|
[/table]
数据行在页头之后,按顺序存储在页中。在页的底部有一个记录每行偏移量的表格,这个偏移量表格的每行对应于页中的每行记录。每个偏移量用来表示每行记录的第一个字节与页开始的
位置的距离。偏移量表格中行与页中行的顺序相反。
[img]http://dl.iteye.com/upload/attachment/151965/431e2cc7-3b0d-33b0-9163-6bae6910062b.gif[/img]
[size=medium][b]盘区(Extents)[/b][/size]
盘区是管理磁盘空间的基本单元。每个盘区是由物理上连续的8个页构成,也就是说,每兆磁盘空间可以容纳16个盘区。
为了更有效分配空间,SQL Server不为小数据量的表分配一个完整的盘区。SQL Server有两种类型盘区:
[list]
[*]uniform extents:由一个对象拥有,该盘区中8个页只能有拥有者来使用
[*]Mixed extents:可以由8个对象拥有,8个页可以由不同对象使用。
[/list]
一个新表或索引通常是从混合盘区中分配页,当表或索引的大小增长超过了8页,那么就以uniform extents方式进行分配。当在已存在的表上创建索引,如果表中行对应的索引大小超过了8页,也以uniform extents方式分配空间。
[img]http://dl.iteye.com/upload/attachment/151973/c3e79cf2-fa63-3582-b47d-b8c66e167905.gif[/img]
SQL Server中最基本的存储单元是页(page)。系统给数据库文件(.mdf .ndf)分配的磁盘空间逻辑上被分解为从0..n的多个编号连续的页。磁盘的I/O操作是在页级水平完成的,也就是说,SQL Server每次读或写整个的数据页(data page).
盘区(Extent)是物理上连续的8个页,这样便于有效地管理页,所有的页都存储在盘区。
[size=medium][b]页(Pages)[/b][/size]
在SQL Server中,页的大小为8KB。这意味着1M字节可以有128页。每页有一个96字节的页头(Header),页头用来存储页的系统信息,具体包括:页编号,页类型、该页剩余空闲空间、
[b]下面表列出了SQL Server的数据文件中所用的页的类型[/b]
[table]
| page Type | contents |
| Data |Data rows with all data, except text, ntext, image, nvarchar(max), varchar(max), varbinary(max), and xml data, when text in row is set to ON.|
|Index|Index entries.|
|Text/Image|Large object data types:
* text, ntext, image, nvarchar(max), varchar(max), varbinary(max), and xml data
Variable length columns when the data row exceeds 8 KB:
* varchar, nvarchar, varbinary, and sql_variant |
|Global Allocation Map, Shared Global Allocation Map|Information about whether extents are allocated.|
|Page Free Space|Information about page allocation and free space available on pages.|
|Index Allocation Map|Information about extents used by a table or index per allocation unit.|
|Bulk Changed Map|Information about extents modified by bulk operations since the last BACKUP LOG statement per allocation unit.|
|Differential Changed Map|Information about extents that have changed since the last BACKUP DATABASE statement per allocation unit.|
[/table]
数据行在页头之后,按顺序存储在页中。在页的底部有一个记录每行偏移量的表格,这个偏移量表格的每行对应于页中的每行记录。每个偏移量用来表示每行记录的第一个字节与页开始的
位置的距离。偏移量表格中行与页中行的顺序相反。
[img]http://dl.iteye.com/upload/attachment/151965/431e2cc7-3b0d-33b0-9163-6bae6910062b.gif[/img]
[size=medium][b]盘区(Extents)[/b][/size]
盘区是管理磁盘空间的基本单元。每个盘区是由物理上连续的8个页构成,也就是说,每兆磁盘空间可以容纳16个盘区。
为了更有效分配空间,SQL Server不为小数据量的表分配一个完整的盘区。SQL Server有两种类型盘区:
[list]
[*]uniform extents:由一个对象拥有,该盘区中8个页只能有拥有者来使用
[*]Mixed extents:可以由8个对象拥有,8个页可以由不同对象使用。
[/list]
一个新表或索引通常是从混合盘区中分配页,当表或索引的大小增长超过了8页,那么就以uniform extents方式进行分配。当在已存在的表上创建索引,如果表中行对应的索引大小超过了8页,也以uniform extents方式分配空间。
[img]http://dl.iteye.com/upload/attachment/151973/c3e79cf2-fa63-3582-b47d-b8c66e167905.gif[/img]