SQL Server Storage Inside. About Hemantgiri S. Goswami Hemantgiri S. Goswami is a Lead Database Consultant for Pythian, a company head quartered in Ottawa,

Slides:



Advertisements
Similar presentations
Module 2: Database Architecture
Advertisements

Chapter 4 : File Systems What is a file system?
A HEAP OF CLUSTERS A look into heaps vs. clustered tables Ami Levin CTO, DBSophic X.
Chapter 11: File System Implementation
File System Implementation
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
Harvard University Oracle Database Administration Session 5 Data Storage.
André Kamman Friday November 20 SQLBITS IV. About Me  André Kamman  > 20 years in IT  Main focus on complex SQL Server environments (or a whole.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Chapter 4 SQL. SQL server Microsoft SQL Server is a client/server database management system. Microsoft SQL Server is a client/server database management.
Chapter 2: Designing Physical Storage MCITP Administrator: Microsoft SQL Server 2005 Database Server Infrastructure Design Study Guide (70-443)
1 Demystifying the Transaction Log. 2 Rob Canzonire Advisory Database Administrator at Blue Cross Blue Shield of Louisiana Microsoft Certified Solutions.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Data Recovery and Fixing Database Corruptions
Databases Lesson 5.
Architecture Rajesh. Components of Database Engine.
MS SQL by: Bryan Bankhead CIS 407. General Concepts  Backing up and Restoring databases and transaction logs is a way that SQL Server provides protection.
Pedro Azevedo Lopes Premier Field Engineer Microsoft Corporation.
IN-MEMORY OLTP By Manohar Punna SQL Server Geeks – Regional Mentor, Hyderabad Blogger, Speaker.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
File System Implementation
12.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 12: File System Implementation Chapter 12: File System Implementation.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File System Implementation.
11.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 11.5 Free-Space Management Bit vector (n blocks) … 012n-1 bit[i] =  1  block[i]
Backup and Recovery - II - Checkpoint - Transaction log – active portion - Database Recovery.
Chapter 5 Record Storage and Primary File Organizations
Storage Tuning for Relational Databases Philippe Bonnet – Spring 2015.
SQL Server Internals 101 AYMAN SENIOR MICROSOFT.
Database Administration for the Non-DBA Denny Cherry twitter.com/mrdenny.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 12: File System Implementation.
Inside transaction logging
Curacao SQL Saturday June 11, 2016
Module 11: File Structure
What Is a Latch? …and Why Do I Care? Eddie Wuerch, mcm
A Day in the Life of a Row Eddie Wuerch, mcm
File-System Implementation
CHP - 9 File Structures.
What Is a Latch? …and Why Do I Care? Eddie Wuerch, mcm
Dynamic Hashing (Chapter 12)
Chapter 11: File System Implementation
Database Management Systems (CS 564)
Chapter Overview Understanding the Database Architecture
Introduction to SQL Server Management for the Non-DBA
Paging Examples Assume a page size of 1K and a 15-bit logical address space. How many pages are in the system?
Lecture 10: Buffer Manager and File Organization
The Vocabulary of Performance Tuning
The Vocabulary of Performance Tuning
Chapter 11: File System Implementation
Database Implementation Issues
What Is a Latch? …and Why Do I Care? Eddie Wuerch, mcm
The Vocabulary of Performance Tuning
Backup and Restore your SQL Server Database
Chapter 11: File System Implementation
Inside transaction logging
Introduction to Database Systems
Indexing and Hashing Basic Concepts Ordered Indices
Outline Allocation Free space management Memory mapped files
Introduction to Operating Systems
Overview: File system implementation (cont)
File-System Structure
It’s TEMPDB Why Should You Care?
The Vocabulary of Performance Tuning
Chapter 14: File-System Implementation
Chapter 11 Managing Databases with SQL Server 2000
Chapter 11: File System Implementation
File System Implementation
The Vocabulary of Performance Tuning
CS222/CS122C: Principles of Data Management UCI, Fall 2018 Notes #03 Row/Column Stores, Heap Files, Buffer Manager, Catalogs Instructor: Chen Li.
Database Implementation Issues
Presentation transcript:

SQL Server Storage Inside

About Hemantgiri S. Goswami Hemantgiri S. Goswami is a Lead Database Consultant for Pythian, a company head quartered in Ottawa, Canada. Hemantgiri has close to 17 years of experience and has worked for fortune 500 companies. Hemantgiri has been awarded Most Valuable Professional (MVP) award by MS for his contribution to community. Hemantgiri is a published author, MSDN Moderator and active blogger. Hemantgiri is a founder and leader of Surat SQLPASS Chapter.

Agenda  We will understand SQL Server Storage  How the data is stored inside  What is PAGE  What is Extent  What is Mixed Extent  TIP: SQL Server storage best practice

SQL Server Storage  Pages  Extents  Uniform  Mixed  Special Type of Pages  Global Allocation Map  Shared Global Allocation MAP

Pages  They are logical  Each page are 8KB in size  They are stored and numbered sequentially from 0 to N in each file  There will be 128 Pages per MB  When a space is added or shrink in a database file, SQL Server ensures page number are contiguous

Pages  Mainly 3 Section 1. Page Header 2. Data Row 3. Row Offset 8 KB = 8192 Bytes Page Header = 96 Bytes Row Offset = 36 Bytes Data Row = 8060 Bytes

Page – What it contains Byte for Header Information such as type of page, amount of free space, object owing 2. Data Row which is place serially 3. At the bottom of the row, there will be a row offset – one for every row, and its offset from start of the page. 4. Row Offset = Information which will let you know how far the row is from start of the page. And, Row Offsets are in reverse sequence from the sequence of the Row 5. Maximum amount of data in single row is 8060 bytes and is called In-Row Data. This limit is relaxed in SQL Server 2008 onwards, and is called Row- Overflow. 6. Row-Overflow Data, SQL Server will still have 8KB Pages but what it will do is that when table have varchar, nvarchar, varbinary or sql_variant or CLR UD columns it will have 24 byte pointer value in original page and move largest width column to another page in ROW_OVERFLOW_DATA unit

Basic Layout of Page 1. Page 0 is the File Header 2. Page 1 is the Page Free Space (PFS) 3. Page 2 is GAM 4. Page 3 is SGAM 5. Page 6 is Differential Changed Map (DCM) 6. Page 7 is Bulk Changed Map (BCM)

Global Allocation Map (GAM)  These pages record which extents have been allocated for any type of use.  GAM has a bit to indicate value 0 means in use and 1 means free extent.  After header and other overhead are accounted, there are 8000 bytes or bits to cover extents.  Each GAM page covers 4 GB of data and a GAM page exists in a file for every 4 GB of file size.

Shared Global Allocation Map (SGAM)  Record which extents are currently used as mixed events and have at least one unused page.  Similar to GAM, it covers extents every 4GB of data.  Has a bit for each extent in the interval it covers: 1 if the extent is being used a mixed extent and has free pages, 0 if the extent isn’t being used a mixed extent or it’s a mixed extent with no free pages

Differential Changed Map (DCM)  This tracks the extents that have changed since the last BACKUP DATABASE statement. If the bit for an extent is 1, the extent has been modified since the last BACKUP DATABASE statement. If the bit is 0, the extent has not been modified.  Differential backups read just the DCM pages to determine which extents have been modified. This greatly reduces the number of pages that a differential backup must scan. The length of time that a differential backup runs is proportional to the number of extents modified since the last BACKUP DATABASE statement and not the overall size of the database.

Bulk Changed Map (BCM)  This tracks the extents that have been modified by bulk logged operations since the last BACKUP LOG statement. If the bit for an extent is 1, the extent has been modified by a bulk logged operation after the last BACKUP LOG statement. If the bit is 0, the extent has not been modified by bulk logged operations.  Although BCM pages appear in all databases, they are only relevant when the database is using the bulk-logged recovery model. In this recovery model, when a BACKUP LOG is performed, the backup process scans the BCMs for extents that have been modified. It then includes those extents in the log backup. This lets the bulk logged operations be recovered if the database is restored from a database backup and a sequence of transaction log backups. BCM pages are not relevant in a database that is using the simple recovery model, because no bulk logged operations are logged. They are not relevant in a database that is using the full recovery model, because that recovery model treats bulk logged operations as fully logged operations.  The interval between DCM pages and BCM pages is the same as the interval between GAM and SGAM page, 64,000 extents. The DCM and BCM pages are located behind the GAM and SGAM pages in a physical file:

Extents  Is a unit  Extent is made up of 8 logically contiguous pages  Extent = 8 Pages of 8 KB each thus 64 KB in size

Types of Extent  Uniform Extents – Owned by Single Object, all eight pages in the extent can be used by this single object.  Mixed Extents – Shared between objects, up to eight objects can share extent Whenever a new table or index needs allocation it is given a mixed extents; when the table or index grows to eight pages, future allocations can use uniform extents. Between versions of SQL Server the # of pages post which uniform extents are given may vary. If a table or index needs more space and is still less than 8 pages total, SQL Server must find a mixed extent with space available, else if it is 8 pages or larger, uniform extents are located. When there is no mixed extents with free space, a new extent marked as mixed extent is allocated and SGAM updated accordingly.

Reference & Further Reading maps/

Contact Information  Twitter : twitter.com/ghemant  Facebook : facebook.com/sqlservercitation  Hemantgiri [at] sql-server-citation.com  Blog :  Linkedin :