InnoDB空间文件布局的基础

In On learning InnoDB: A journey to the core, I introduced the innodb_diagrams project to document the InnoDB internals, which provides the diagrams used in this post.

On learning InnoDB: A journey to the core中,我介绍了innodb_diagrams项目,用于记录InnoDB内部结构,提供了本文中使用的图表。

InnoDB’s data storage model uses “spaces”, often called “tablespaces” in the context of MySQL, and sometimes called “file spaces” in InnoDB itself. A space may consist of multiple actual files at the operating system level (e.g. ibdata1, ibdata2, etc.) but it is just a single logical file — multiple physical files are just treated as though they were physically concatenated together.

InnoDB的数据存储模型使用“空间”,在MySQL的上下文中通常称为“表空间”,在InnoDB本身中有时称为“文件空间”。一个空间可以由操作系统级别的多个实际文件组成(例如ibdata1、ibdata2等),但它只是一个单一的逻辑文件,多个物理文件只是被视为物理上连接在一起。

Each space in InnoDB is assigned a 32-bit integer space ID, which is used in many different places to refer to the space. InnoDB always has a “system space”, which is always assigned the space ID of 0. The system space is used for various special bookkeeping that InnoDB requires. Through MySQL, InnoDB currently only supports additional spaces in the form of “file per table” spaces, which create an .ibd file for each MySQL table. Internally, this .ibd file is actually a fully functional space which could contain multiple tables, but in the implementation with MySQL, they will only contain a single table.

InnoDB 中的每个空间都被分配一个 32 位整数空间 ID,该 ID 在许多不同的地方用于引用该空间。InnoDB 总是有一个“系统空间”,该空间始终被分配为空间 ID 0。系统空间用于各种 InnoDB 需要的特殊簿记。通过 MySQL,InnoDB 目前仅支持以“每个表一个文件”的形式创建附加空间,这为每个 MySQL 表创建了一个 .ibd 文件。在内部,这个 .ibd 文件实际上是一个完全功能的空间,可以包含多个表,但在与 MySQL 的实现中,它们只包含一个表。

Pages

页面

Each space is divided into pages, normally 16 KiB each (this can differ for two reasons: if the compile-time define UNIV_PAGE_SIZE is changed, or if InnoDB compression is used). Each page within a space is assigned a 32-bit integer page number, often called “offset”, which is actually just the page’s offset from the beginning of the space (not necessarily the file, for multi-file spaces). So, pag...

开通本站会员,查看完整译文。

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-23 01:52
浙ICP备14020137号-1 $访客地图$