NOTE

1.34 InnoDB Tablespaces

Tablespaces are a logical way to organize InnoDB data. These notes explain storage through the relationships among tablespaces, segments, extents, and pages.

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.
  • Extents are organized into groups of 256, 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 at separate locations 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