5/8/2025
SQL Server Page Architecture
Bhargav Mallapu
OSI DIGITAL PVT LTD
SQL Server Page Architecture
Bhargav Reddy
SQL DBA
+91 - 7386137157
1. What is a Page?
• A page is the smallest unit of I/O SQL Server reads/writes.
• Every operation at the disk or buffer pool level is page-based, not row-based.
• Fixed size: 8 KB (8192 bytes).
________________________________________
2. Page Layout (Internal Structure):
Each 8 KB page is structured as follows:
| 96 bytes Page Header | Data rows / index entries | Slot Array (Row Offset Table) |
Page Header (96 bytes):
Contains metadata:
• Page ID (file ID + page number)
• Page type
• Object ID (which table/index this belongs to)
• LSN (Log Sequence Number)
• Flags (e.g., is this a ghost record page?)
• Free space tracking
Data Rows / Index Entries:
• Stored starting after the header.
• Inserted bottom-up in the page.
Slot Array:
• Stores row pointers (offsets).
• Grows top-down.
• Used for logical row ordering (especially for heaps).
________________________________________
3. Page Types
Page Type Description
Data Page Contains actual row data for tables
Index Page Used in B-tree indexes (non-leaf levels)
Text/Image Page Used for LOB data (text, varchar(max))
GAM Page Global Allocation Map – tracks if extents are free
SGAM Page Shared GAM – tracks mixed extents and free pages
PFS Page Page Free Space – tracks page-level allocation and usage
IAM Page Index Allocation Map – maps object to extents
Boot Page Metadata for database startup (only one per DB)
1|Page
SQL Server Page Architecture
Bhargav Reddy
SQL DBA
+91 - 7386137157
Commands:
DBCC TRACEON(3604);
DBCC PAGE('DBName', FileID, PageID, 3);
________________________________________
4. Extents: How SQL Server Allocates Pages:
• Extent = 8 pages = 64 KB
Types of extents:
Uniform Extents: All 8 pages used by 1 object
Mixed Extents: Pages used by different objects (used for small tables)
SQL Server allocates pages as:
• First 8 pages: From mixed extents
• Next: Uniform extents
________________________________________
5. Row Structure (Inside Pages)
Each row has:
• Row header: 4–24 bytes (status bits, length)
• Fixed-length columns: Stored directly
• Variable-length columns: Managed via offset array
• NULL bitmap
• Optional off-row LOB pointers
Max row size in a single page: 8,060 bytes
(If row is larger → LOB data stored in separate pages)
________________________________________
6. Specialized Pages:
PFS (Page Free Space)
• Every 8,088 pages = 1 PFS page
Tracks:
Page allocation
Row count on page
Ghost records
Amount of free space
GAM & SGAM:
• GAM: Marks free extents (1 GAM for every 64,000 extents)
• SGAM: Marks extents with mixed pages that can still allocate
IAM (Index Allocation Map):
• Tracks page allocations per allocation unit (per table/index/partition)
________________________________________
7. Page Lifecycle:
1. Query runs → needs a row
2. SQL Server checks Buffer Pool (memory cache)
3. If page not in memory → Read from disk (8 KB I/O)
4. Page now in buffer → Read/write happens in RAM
5. Modified page is marked dirty
6. Flushed to disk during:
2|Page
SQL Server Page Architecture
Bhargav Reddy
SQL DBA
+91 - 7386137157
Lazy writer
Checkpoint
Log flush due to commit
________________________________________
8. Ghost Records:
• Deleted rows are not immediately removed.
• They are marked as ghost and cleaned later by a background task.
• Helps maintain index page stability during concurrent operations.
________________________________________
9. Query Performance & Pages:
• Page splits: When a row is inserted into a full index page → costly.
• Forwarded records: In heaps, updates may forward row to a new page.
• Read-ahead: SQL Server may perfects pages during scans.
Use DMVs like:
SELECT * FROM sys.dm_db_index_physical_stats;
To monitor fragmentation, page usage, etc.
________________________________________
10. Monitoring and Debugging:
View which pages are used by a table:
SELECT *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID('YourTable'), NULL, NULL,
'DETAILED');
View page internals:
DBCC IND('YourDB', 'YourTable', 1); -- List of pages
DBCC PAGE('YourDB', 1, PageID, 3); -- Page structure
________________________________________
Summary Diagram (Textual):
[ Data File ]
└── Extent (64 KB)
├── Page 1 (8 KB)
│ └── Page Header (96 B)
│ └── Data Rows
│ └── Slot Array
├── Page 2 ...
________________________________________
3|Page
SQL Server Page Architecture
Bhargav Reddy
SQL DBA
+91 - 7386137157
Summary:
Concept Key Point
Page Smallest data storage unit (8 KB)
Extent 8 pages = 64 KB, allocated to objects
Allocation Managed by PFS, GAM, SGAM, IAM
Page Access Memory (buffer pool) or Disk
Page Internals Header, Data rows, Slot array
Performance Tip Monitor fragmentation, ghost records, page splits
4|Page