《Microsoft Sql server 2008 Internals》索引目录:《Microsoft Sql server 2008 Internals》读书笔记--目录索引
在上一篇中,我们主要学习了如何在系统视图中察看我们创建表和索引的元数据信息,今天,我们继续学习数据存储的元数据结构。
数据存储元数据(Data Storage Metadata)
还记得Haep吗?就是没有聚集索引的表。每一个Heap和索引都在sys.indexes视图中有一行记录,SQL2008中每个表和索引能被存储在多个分区中。sys.Partitions包含一个Row对应于每一个Heap或索引的分区。每一个Heap或索引至少有一(到1000)个分区,即使你没有定义分区结构。因此,sys.indexes与sys.Partitions是一对多的关系,在SQL2008中用了一个词"hobt"(Heap Or B-Tree)来称谓表或索引在一个分区中的子集(subset),所以在sys.partitions中有一列是hobt_id。实际上,hobt_id和partition_id是一一对应关系。这两列的值也完全一样。
示例:
结果:
每一个分区(无论是一个Heap或者索引)能存储三种类型的行,分别存储在自己特定的页面(pages)中。即in-row data pages(可以理解为规则数据)、row-overflow data pages和LOB data pages。针对于一个特定分区的一个特定的页面被称为allocation unit(分配单元),每个分区在视图sys.allocation_units中有多个行,因为每个分区我们多个分配单元。总有一个分配单元针对n-row data,也可能有分配单元针对LOB data和row-overflow data,下图展示了这种关系:
查询目录视图(Querying Catalog Views)
其实前面已经多次应用,这里我们再练习一下sys.allocation_units
结果如下:
再增加不“规则列”
结果:
你也可发创建一个或两个索引来测试索引视图,应该注意到仅仅增加一个聚集索引并不会改变sys.allocation_units的行数,但却改变了partition_id 数字,因为创建一个聚集索引的时候表完全被内部重建了。你可以从经下语句的结果中看到这个差异:
大家可能注意到rows和Pages都是0,那是因为我们还没有插入任何数据。
到目前为止,我们并没有查询关于page的分配信息情况。在SQL2000中sysindexes表包含了三列关于空间分配的信息:first,root和firstIAM,
在SQL2008中这三个列名改为first_page,root_page,和first_iam_page,但只在MSDN未公开的sys.system_allocation_units中可以查到。而公开的一个视图是sys.allocation_units。看来,微软还是藏了不少压箱货啊!呵呵。
关于更多的目录视图的知识,请看MSDN:
http://msdn.microsoft.com/zh-cn/library/ms174365%28SQL.90%29.aspx
下一节将更深入学习数据页Data Pages
邀月注:本文版权由邀月和CSDN共同所有,转载请注明出处。
助人等于自助! 3w@live.cn
分享到:
相关推荐
Microsoft SQL Server 2008 internals (PDF 高清版)
Microsoft SQL Server 2008 Internals_中文 Microsoft SQL Server 2008 Internals_中文 Microsoft SQL Server 2008 Internals_中文
Microsoft SQL Server 2008 Internals
[Microsoft Press] Microsoft SQL Server 2012 Internals (E-Book) ☆ 图书概要:☆ Dive deep inside the architecture of SQL Server 2012 Explore the core engine of Microsoft SQL Server 2012—and put ...
SQL Server 2008 Internals and Troubleshooting for DBA and developer
(1)Inside Microsoft SQL Server 2008 T-SQL Querying (2)Inside Microsoft SQL Server 2008 T-SQL Programming (3)Professional SQL Server 2008 Internals andTroubleshooting
Kalen has been working with SQL Server since 1987, specializing in query performance tuning and SQL Server internals. The Hekaton internals knowledge she provides in this book will help you migrate ...
Professional SQL Server 2012 Internals and Troubleshooting
Microsoft.SQL.Server.2008.Internals 英文版
英文版,文档版PDF,非扫描版,可复制内容。
Pro SQL Server Internals is a book for developers and database administrators, and it covers multiple SQL Server versions starting with SQL Server 2005 and going all the way up to the recently ...
由Kalen Delaney编写的微软SQL Server图书一直是同类图书中的佼佼者,是SQL Sewer开发人员、架构师和DBA的案头必备书。如今。这本新书纳入微软阵容空前的“深入解析”(Internals)系列。微软SQL Server开发团队必读...
Microsoft SQL Server 2012 Internals 英文文字版,带目录
Microsoft SQL Server 2012 Internals.pdf 英文清晰版本
Inside Microsoft SQL Server 2008: T-SQL Querying puts together all the ingredients you need to understand this declarative and set-oriented way of thinking and become a profi cient SQL programmer, ...
Kindle to PDF version. High definition with bookmarks.