官术网_书友最值得收藏!

Data files

Every database must have at least one data file called primary data file. This file is always bound to the primary filegroup. In this file is all the metadata of the database, such as structure descriptions (could be seen through views such as sys.objects, sys.columns, and others), users, and so on. If the database does not have other data files (in the same or other filegroups), all user data is also stored in this file, but this approach is good enough just for smaller databases.

Considering how the volume of data in the database grows over time, it is a good practice to add more data files. These files are called secondary data files. Secondary data files are optional and contain user data only.

Both types of data files have the same internal structure. Every file is pided into 8 KB small parts called data pages. SQL Server maintains several types of data pages such as data, data pages, index pages, index allocation maps (IAM) pages to locate data pages of tables or indexes, global allocation map (GAM) and shared global allocation maps (SGAM) pages to address objects in the database, and so on. Regardless of the type of a certain data page, SQL Server uses a data page as the smallest unit of I/O operations between hard disk and memory. Let's describe some common properties:

  • A data page never contains data of several objects
  • Data pages don't know each other (and that's why SQL Server uses IAMs to allocate all pages of an object)
  • Data pages don't have any special physical ordering
  • A data row must always fit in size to a data page

These properties could seem to be useless but we have to keep in mind that when we know these properties, we can better optimize and manage our databases.

Did you know that a data page is the smallest storage unit that can be restored from backup?

As a data page is quite a small storage unit, SQL Server groups data pages into bigger logical units called extents. An extent is a logical allocation unit containing eight coherent data pages. When SQL Server requests data from disk, extents are read into memory. This is the reason why 64 KB NTFS clusters are recommended to format disk volumes for data files. Extents could be uniform or mixed. Uniform extent is a kind of extent containing data pages belonging to one object only; on the other hand, a mixed extent contains data pages of several objects.

主站蜘蛛池模板: 天柱县| 泾阳县| 新竹县| 九江县| 邻水| 正镶白旗| 西贡区| 安义县| 铜川市| 民和| 泾川县| 礼泉县| 临桂县| 莱州市| 寻甸| 丹棱县| 农安县| 元江| 八宿县| 五大连池市| 安岳县| 黎川县| 城口县| 沈丘县| 大埔县| 上思县| 绥化市| 响水县| 罗江县| 玉门市| 开鲁县| 南溪县| 安康市| 开封县| 三河市| 阜平县| 富民县| 无锡市| 织金县| 宣武区| 柘荣县|