Pages and Extents

The fundamental unit of data storage in SQL Server is the page. In SQL Server 7.0, the page size is 8 KB, increased from 2 KB. At the start of each page is a 96-byte header used to store system information such as the type of page, the amount of free space on the page, and the ID of the object owning the page.

There are seven page types in the data files of a SQL Server 7.0 database.

Page type Contains
Data Data rows with all data types except text, ntext, and image
Index Index entries
Log Log records recording data changes for use in recovery
Text/Image text, ntext, and image data types
Global Allocation Map Information about allocated extents
Page Free Space Information about free space available on pages
Index Allocation Map Information about extents used by a table or index

Data pages contain all the data types in data rows except text, ntext, and image, which are stored in separate pages. Data rows are placed serially on the page starting immediately after the header. A row-offset table starts at the end of the page.

The row-offset table contains one entry for each row on the page. Each entry records how far from the start of the page the first byte of the row is. The entries in the row-offset table are in reverse sequence from the sequence of the rows on the page. In SQL Server 7.0, rows cannot span pages, and the maximum amount of data contained in a single row is 8,060 bytes, not including the text, ntext, and image data types.

Extents are the basic unit in which space is allocated to tables and indexes. An extent is eight contiguous pages, or 64 KB. To make its space allocation efficient, SQL Server 7.0 does not allocate entire extents to tables with small amounts of data.

SQL Server 7.0 has two types of extents: uniform and mixed. Uniform extents are owned by a single object; all pages in the extent can be used only by the owning object.

Mixed extents, introduced in SQL Server 7.0, work well for small applications. In SQL Server, space is added to tables one extent at a time. In SQL Server 7.0, this can lead to a large overhead for tiny tables because pages are 8 KB. A mixed extent allows allocation of a single page to a small table or index. Only when the table or index has allocated more than eight pages will it begin to allocate uniform extents. Mixed extents are shared by up to eight objects. A new table or index is allocated pages from mixed extents. When a table or index grows to eight pages, it is switched to uniform extents.