{"id":6171,"date":"2013-08-01T14:45:11","date_gmt":"2013-08-01T14:45:11","guid":{"rendered":"http:\/\/craftydba.com\/?p=6171"},"modified":"2016-04-21T21:21:31","modified_gmt":"2016-04-21T21:21:31","slug":"page-anatomy-part-2","status":"publish","type":"post","link":"https:\/\/craftydba.com\/?p=6171","title":{"rendered":"Page Anatomy &#8211; Part 2"},"content":{"rendered":"<p>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 <span style=\"color: #dd0000\">Database Boot Page<\/span>.<\/p>\n<p>All of the information is a gleamed from SQL Server 2008 Internals book by <a href=\"http:\/\/www.sqlserverinternals.com\/\">Kalen Delaney<\/a>. If it is not on your bookshelf, I suggest you go out and by a copy. The online MCM training videos from <a href=\"http:\/\/www.sqlskills.com\/sql-server-resources\/sql-server-mcm-training-videos\/\">Paul Randal<\/a> are also an excellent resource.<\/p>\n<p>A single page (8K) is the smallest unit in which SQL Server allocates resources.  However, most times the storage engine allocates resources in <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms190969(v=sql.105).aspx\">extents<\/a> (64K) which are a block of 8 pages.  <\/p>\n<p>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.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/08\/sql-server-extents.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/08\/sql-server-extents.gif\" alt=\"\" width=\"408\" height=\"155\" class=\"aligncenter size-full wp-image-6174\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/08\/sql-server-extents.gif 408w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/08\/sql-server-extents-300x113.gif 300w\" sizes=\"auto, (max-width: 408px) 100vw, 408px\" \/><\/a><\/p>\n<p>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.<\/p>\n<p><span style=\"color: #003399;font-size: 14px\"><u>Fixed Page Locations<\/u><\/span><\/p>\n<ol>\n<li>File Header page is located on page zero.<\/li>\n<p><\/p>\n<li>Page Free Space (PFS) page is located on page one.<\/li>\n<p><\/p>\n<li>Global Allocation Map (GAM) page is located on page two.<\/li>\n<p><\/p>\n<li>Shared Global Allocation Map (SGAM) page is located on page three.<\/li>\n<p><\/p>\n<li>Differential Change Map (DCM) page is located on page six.<\/li>\n<p><\/p>\n<li> Minimally Logged (ML) page is located on page seven.<\/li>\n<p><\/p>\n<li> Database Boot page is located on page nine.<\/li>\n<\/ol>\n<p>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.<\/p>\n<p><span style=\"color: #003399;font-size: 14px\"><u>Page Types<\/u><\/span><\/p>\n<p> 1  = Data page<br \/>\n 2  = Index page<br \/>\n 3  = Text mix page<br \/>\n 4  = Text tree page<br \/>\n 7  = Sort page<br \/>\n 8  = GAM page<br \/>\n 9  = SGAM page<br \/>\n 10 = IAM page<br \/>\n 11 = PFS page<br \/>\n 13 = Boot page<br \/>\n 15 = File header page<br \/>\n 16 = Diff map page<br \/>\n 17 = ML map page<\/p>\n<p>Again, I will be using my sample [pubs] database that contains one [title] table.  The <a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/07\/pubs-db-with-titles-table.sql_.txt\">script<\/a> is enclosed just in-case you do not already have it.<\/p>\n<p>There are two quick ways to dump the database boot page.  The code snippet demonstrating both solutions is below.<\/p>\n<pre class=\"lang:TSQL theme:familiar mark:1,2-3\" title=\"database boot page\">\r\n--\r\n-- Show the database boot page\r\n--\r\n\r\n-- 1 - database boot page\r\ndbcc dbinfo ('pubs') with tableresults;\r\n\r\n-- enable output to client \r\ndbcc traceon (3604, -1);\r\n\r\n-- 2 - database boot page\r\ndbcc page (pubs, 1, 9, 3);\r\n\r\n-- disable output to client \r\ndbcc traceoff (3604, -1);\r\n\r\n<\/pre>\n<p><\/span><\/p>\n<p>The first way is to call the <span style=\"color: #008000\">DBCC DBINFO<\/span> undocumented command with the name of the database. The <span style=\"color: #008000\">&#8216;with tableresults&#8217;<\/span> option can be used to save the data in a tabular format.  <\/p>\n<p>The following fields are of real interest to me.<\/p>\n<ol>\n<li>dbi_dbname = name of the database.<\/li>\n<li>dbi_dbid = id associated with the database.<\/li>\n<li>dbi_cmptlevel = compatibility level of the database.<\/li>\n<li>dbi_dbccLastKnownGood = last time a CHECKDB was ran.<\/li>\n<\/ol>\n<p>The full first output can be viewed <a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/08\/dbcc-info-output.xlsx\">here<\/a>.<\/p>\n<p>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).  <\/p>\n<p><span style=\"color: #003399;font-size: 14px\"><u>Print Option Decode<\/u><\/span><\/p>\n<p>0 &#8211; print just the page header<br \/>\n1 &#8211; page header plus per-row hex dumps, plus the page slot array<br \/>\n2 &#8211; page header plus whole page hex dump<br \/>\n3 &#8211; page header plus detailed per-row interpretation<\/p>\n<p>The database boot record is on page nine in the database.  The full second output can be viewed <a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/08\/dbcc-page-nine-boot-page.txt\">here<\/a>.<\/p>\n<p>Next time I will be talking about <span style=\"color: #dd0000\">Global Allocation Map<\/span> (GAM) Pages.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6098,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[901,909,31,908,535,903,536,537,15,910,911,28,29],"class_list":["post-6171","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-db-admin","tag-administrator","tag-database-boot-page","tag-database-developer","tag-dbcc-dbinfo","tag-dbcc-page","tag-dbcc-traceoff","tag-dbcc-traceon","tag-flag-3604","tag-john-f-miner-iii","tag-page-9","tag-page-type-13","tag-sql-server","tag-tsql"],"_links":{"self":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/6171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6171"}],"version-history":[{"count":0,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/6171\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/media\/6098"}],"wp:attachment":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}