Quantcast
Channel: Jimmy He – OracleBlog
Viewing all articles
Browse latest Browse all 130

SQL Server数据文件结构

$
0
0

Data file 结构:

第一个extent:

page 0 : File Header,注m_type = 15,Metadata: ObjectId = 99

page 1 : PFS( page free space),注m_type = 11,Metadata: ObjectId = 99

page 2 : GAM ( global allocation map),注m_type = 8,Metadata: ObjectId = 99,每个GAM管理4GB的页面,所以每隔4GB大小的页面,会有一个GAM。

page 3 : SGAM ( shared global allocation map),注m_type = 9,Metadata: ObjectId = 99

page 4 : 空的,注m_type = 0,Metadata: ObjectId = 0

page 5 : 空的,注m_type = 0,Metadata: ObjectId = 0

page 6 : DCM(differential change map),注m_type = 16,Metadata: ObjectId = 99

page 7 :BCM(bulk change map),注m_type = 17,Metadata: ObjectId = 99

注意,如果大temp文件(一个超过4G)的page latch,往往是在temp数据文件的第一个extent的第2个page上,其争用可以用下面的sql监控:

select count(*) as cnt from sys.sysprocesses where  DateDiff(ss,last_batch,getDate())>=5 and lastwaittype Like 'PAGE%LATCH_%' And waitresource Like '2:%'

注,争用是指在多个进程都要使用temp数据文件的时候,需要找temp文件的free space,而free space的元数据,是记录在GAM中的。在GAM中容易出现争用。解决方案是使用多个temp数据文件,

第二个extent:

page 8 : DATA,注m_type = 1,Metadata: ObjectId = 90 ,类似sysqnames 这样的system base table,基表。

page 9 : Boot Page,包含启动数据库的信息,注m_type = 13,Metadata: ObjectId = 99 ,通常情况,第一个数据文件的第9个page是boot page。

page 10 : IAM,注m_type = 10,Metadata: ObjectId = 44 ,类似sysnsobjs的基表。

page 11 : index page,注m_type = 2,Metadata: ObjectId = xx,基表

page 12 : IAM,注m_type = 10,Metadata: ObjectId = xx,基表

page 13 : IAM,注m_type = 10,Metadata: ObjectId = xx,基表

page 14 : DATA,注m_type = 1,Metadata: ObjectId = xx,基表

page 15 : IAM,注m_type = 10,Metadata: ObjectId = xx,基表

第三个extent:

page 16 : index page,注m_type = 2,Metadata: ObjectId = xx,基表

page 17 : DATA,注m_type = 1,Metadata: ObjectId = xx,基表

page 18 :  IAM,注m_type = 10,Metadata: ObjectId = xx,基表

page 19 :  DATA,注m_type = 1,Metadata: ObjectId = xx,基表

page 20 :  DATA,注m_type = 1,Metadata: ObjectId = xx,基表

page 21 :  IAM,注m_type = 10,Metadata: ObjectId = xx,基表

page 22 :  IAM,注m_type = 10,Metadata: ObjectId = xx,基表

page 23 :  DATA,注m_type = 1,Metadata: ObjectId = xx,基表

参考文档:
《https://docs.microsoft.com/en-us/sql/relational-databases/pages-and-extents-architecture-guide?view=sql-server-ver15》

《人人都是 DBA(VIII)SQL Server 页存储结构》
http://www.cnblogs.com/gaochundong/p/everyone_is_a_dba_sqlserver_page_storage_structure.html

《Sql server page & log file architecture by Sunil Kumar Anna》
https://www.slideshare.net/sunilannakumar/sql-server-page-log-file-architecture


Viewing all articles
Browse latest Browse all 130

Trending Articles


EASY COME, EASY GO


UPDATE SC IDOL: TWO BECOME ONE


Pokemon para colorear


Sapos para colorear


The business quotes | Inspirational and Motivational Quotes for you


Long Distance Relationship Tagalog Love Quotes


5 Tagalog Relationship Rules


“Mali man na ikaw ay ibigin ko, akoy iibig padin sayo”


RE: Mutton Pies (frankie241)


Vimeo 10.7.0 by Vimeo.com, Inc.


FORECLOSURE OF REAL ESTATE MORTGAGE


HOY PANGIT, MAGBAYAD KA!


Girasoles para colorear


tagalog love Quotes – Tiwala Quotes


Patama lines and Tagalog Quotes Pinoy Sayings


Tropa Quotes


Top 10 Best “Single” Tagalog Love Quotes


Re:Mutton Pies (lleechef)


Ka longiing longsem kaba skhem bad kaba khlain ka pynlong kein ia ka...


Vimeo 10.7.1 by Vimeo.com, Inc.