SQL Server Pages and Extents
Q. What is the basic storage unit in SQL Server database?
Page is the basic unit of data storage in SQL Server. Disk space allocated to the data files (.mdf or .ndf) are logically divided into pages. Log files do not contain pages, they contain log records.
Q. What is the size of a data page?
Size of a page in SQL Server is 8KB or 8192 Bytes (1024 bytes * 8KB)
Out of 8192 Bytes,
Header takes 96 Bytes
Row offset takes 36 Bytes.
So, 8192 Bytes - 96 Bytes- 36 Bytes = 8060 Bytes is available to store the actual data.
Q. What happens if the data to be inserted exceeds maximum size of a data page, that is 8KB?
(Row-Overflow Data Exceeding 8 KB)
The maximum amount of data that a page can occupy is 8060 bytes. If the total size of a row exceeds 8060 bytes, SQL Server moves one or more variable length columns to pages in the ROW_OVERFLOW_DATA allocation unit and keeps a pointer to this new page in the original data page.
Q. What are the different types of pages and what are their use?
Different Page types are:
Data, Index, Text/Image, Page Free Space,Global Allocation Map, Shared Global Allocation ,Map, Index Allocation Map, Bulk Changed Map and Differential Changed Map.
1. Data - Use to store all data rows except text, ntext, varchar(max), nvarchar(max), varbinary(max), image and xml data.
2. Index - Used for index entries.
3. Text/Image - Used for text,ntext,varchar(max),nvarchar(max),varbinary(max),image and xml data
4. Page free space - Used to store information about free space available on pages and page allocation details.
5. Global Allocation Map, Shared Global Allocation Map -Information about extents.
6.Index Allocation Map- Information about Index per alocation unit.
7. Bulk Changes Map
8. Differential Changed Map.
Q. What is the structure of a Page.
A Page contain Header, Data rows and Row offset table.
Data rows- Data pages are stored sequentially just after header.
Row offset- Row offset table is stored at the end of the page and contain one entry for each data records which says how far the first bytes of the row from the start of the page.
Q. What is an extent?
An Extent is a set of 8 pages.
Q. What is the size of an Extent?
Since 1 extent occupy 8 pages size of 1 extent is 8KB*8 =64KB.
Q. What are the type of extents
SQL server has 2 types of extents:
Uniform extents and Mixed Extents
Uniform Extents: Uniform extents are owned by single objects. That means all 8 pages in the extents can only used by the owning object.
Mixed Extents: Mixed extents are shared by upto 8 objects.
Ref: msdn.microsoft.com
Understanding Pages and Extents
http://msdn.microsoft.com/en-us/library/ms190969%28v=sql.105%29.aspx
Comments
Post a Comment