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

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.

主站蜘蛛池模板: 区。| 灵丘县| 巨野县| 安阳市| 东山县| 孟津县| 五原县| 宜宾县| 甘南县| 伽师县| 隆安县| 临江市| 彭州市| 吉首市| 安西县| 鄱阳县| 米泉市| 平山县| 平湖市| 潍坊市| 呼图壁县| 朔州市| 民乐县| 额尔古纳市| 太白县| 广西| 宁城县| 汝阳县| 宁津县| 新绛县| 辽宁省| 田东县| 湾仔区| 囊谦县| 阳东县| 正安县| 衡水市| 阳江市| 宁都县| 航空| 五大连池市|