I am going continue my series of articles describing how information is stored and organized in a Microsoft SQL Server database. Today, I am going to talk about the Database Boot Page.
All of the information is a gleamed from SQL Server 2008 Internals book by Kalen Delaney. If it is not on your bookshelf, I suggest you go out and by a copy. The online MCM training videos from Paul Randal are also an excellent resource.
A single page (8K) is the smallest unit in which SQL Server allocates resources. However, most times the storage engine allocates resources in extents (64K) which are a block of 8 pages.
There are two types of extents. Mixed extents which contain data from a variety of objects and uniform extents which contain data from one object. Please see image from MSDN below.
Now that we know how pages are grouped, where are the different pages in our databases located? The list below shows the first occurrence of each page. More details will be covered in-depth in future page articles.
Fixed Page Locations
- File Header page is located on page zero.
- Page Free Space (PFS) page is located on page one.
- Global Allocation Map (GAM) page is located on page two.
- Shared Global Allocation Map (SGAM) page is located on page three.
- Differential Change Map (DCM) page is located on page six.
- Minimally Logged (ML) page is located on page seven.
- Database Boot page is located on page nine.
Where are the data or index pages, the building blocks of every table? There are other pages types inside the database but they do not start at fixed locations. The list below shows all the different page types that you might encounter.
Page Types
1 = Data page
2 = Index page
3 = Text mix page
4 = Text tree page
7 = Sort page
8 = GAM page
9 = SGAM page
10 = IAM page
11 = PFS page
13 = Boot page
15 = File header page
16 = Diff map page
17 = ML map page
Again, I will be using my sample [pubs] database that contains one [title] table. The script is enclosed just in-case you do not already have it.
There are two quick ways to dump the database boot page. The code snippet demonstrating both solutions is below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
-- -- Show the database boot page -- -- 1 - database boot page dbcc dbinfo ('pubs') with tableresults; -- enable output to client dbcc traceon (3604, -1); -- 2 - database boot page dbcc page (pubs, 1, 9, 3); -- disable output to client dbcc traceoff (3604, -1); |
The first way is to call the DBCC DBINFO undocumented command with the name of the database. The ‘with tableresults’ option can be used to save the data in a tabular format.
The following fields are of real interest to me.
- dbi_dbname = name of the database.
- dbi_dbid = id associated with the database.
- dbi_cmptlevel = compatibility level of the database.
- dbi_dbccLastKnownGood = last time a CHECKDB was ran.
The full first output can be viewed here.
The second way is to use trace flag 3604 in conjunction with DBCC PAGE command to dump the page information into the query output window. Supply the undocumented command with the name of the database, the file number, the page number, and the print option (see below).
Print Option Decode
0 – print just the page header
1 – page header plus per-row hex dumps, plus the page slot array
2 – page header plus whole page hex dump
3 – page header plus detailed per-row interpretation
The database boot record is on page nine in the database. The full second output can be viewed here.
Next time I will be talking about Global Allocation Map (GAM) Pages.