NOTE

1.34 InnoDB Tablespaces

1. What Is a Tablespace - A tablespace is an abstract concept - Logically - It can be imagined as a pool of pages - Physically - For the system tablespace, it corresponds to one or more actual files in the file system - By default, InnoDB creates a file named ibdata1 with a size of 12M under the data directory, and the size grows automatically - For each file-per-table tablespace, it corresponds to an actual file named table_name.ibd in the file system 2. Tablespace Structure

DatabasesCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. What Is a Tablespace

  • A tablespace is an abstract concept.
  • Logically:
    • it can be imagined as a pool of pages.
  • Physically:
    • for the system tablespace, it corresponds to one or more actual files in the file system;
      • by default, InnoDB creates a file named ibdata1 with a size of 12M under the data directory, and its size grows automatically;
    • for each file-per-table tablespace, it corresponds to an actual file named table_name.ibd in the file system.

2. Tablespace Structure

2.1. Pages

2.2. Extents

2.2.1. What Is an Extent

  • A tablespace is divided into many contiguous extents, and each extent consists of 64 pages by default.
  • Every 256 extents are divided into a group, and the types of the first few pages in each group are fixed.

2.2.2. Why Divide into Extents

  • Pages themselves are sufficient, but pages are stored discretely and use random I/O.
  • An extent consists of 64 pages that are contiguous in physical location and uses sequential I/O.

2.3. Segments

  • Leaf nodes have their own extents, and non-leaf nodes also have their own extents.
  • The collection of extents that store leaf nodes is a segment, and the collection of extents that store non-leaf nodes is also a segment.

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub