InnoDB磁盘结构之表空间

在这里插入图片描述

1 问题背景

前面研究了InnoDB磁盘架构之索引,今天研究下表空间

2 回顾

InnoDB架构如下图所示:

在这里插入图片描述

3 表空间

官方文档对表空间的介绍非常详情,此处只挑选平常接触得多或者比较重要的章节来研究。详情见Tablespaces

3.1 系统表空间

原文
The system tablespace is the storage area for the change buffer. It may also contain table and index data if tables are created in the system tablespace rather than file-per-table or general tablespaces. In previous MySQL versions, the system tablespace contained the InnoDB data dictionary. In MySQL 8.0, InnoDB stores metadata in the MySQL data dictionary. See Chapter 14, MySQL Data Dictionary. In previous MySQL releases, the system tablespace also contained the doublewrite buffer storage area. This storage area resides in separate doublewrite files as of MySQL 8.0.20. See Section 15.6.4, “Doublewrite Buffer”.

系统表空间是存储更改缓冲区的区域。如果表是在系统表空间创建的,而不是在每个表文件或通用表文件创建的,那么系统表空间可能包含表数据以及索引数据。在以前的MySQL版本,系统表空间包含InnoDB数据字典。在MySQL8.0版本,InnoDB存储元数据在数据字典。详情见MySQL 数据字典。在以前的MySQL版本,系统表空间还包含双写缓冲区存储区。从MySQL8.0.20开始,此存储区域位于单独的双写文件中。详情见Doublewrite Buffer

原文
The system tablespace can have one or more data files. By default, a single system tablespace data file, named ibdata1, is created in the data directory. The size and number of system tablespace data files is defined by the innodb_data_file_path startup option. For configuration information, see System Tablespace Data File Configuration.

系统表空间可以有一个或多个数据文件。默认地,一个名为ibdata1的单个系统表空间数据文件是被创建在数据字典。系统表空间的数据文件大小以及数量是由innodb_data_file_path启动选项定义的。详情见System Tablespace Data File Configuration

3.2 File-Per-Table 表空间

详情见File-Per-Table Tablespaces

原文
A file-per-table tablespace contains data and indexes for a single InnoDB table, and is stored on the file system in a single data file.

每个表的文件表空间包含单个InnoDB表的数据和索引,并存储在文件系统上的单个数据文件中。

本小节将从以下几个方面去阐述 File-per-table 表空间的特点:

  • File-Per-Table 表空间的配置
  • File-Per-Table 表空间的数据文件
  • File-Per-Table 表空间的优点
  • File-Per-Table 表空间的缺点

3.2.1 File-Per-Table 表空间配置

此处不赘述,详情见File-Per-Table Tablespace Configuration

3.2.2 File-Per-Table 表空间数据文件

原文
A file-per-table tablespace is created in an .idb data file in a schema directory under the MySQL data directory. The .ibd file is named for the table (table_name.ibd). For example, the data file for table test.t1 is created in the test directory under the MySQL data directory

一个 file-per-table表空间被创建并存储在名为表名.idb文件上。该文件是在MySQL的data目录下的以表名为目录的路径上,如下所示:

mysql> USE test;

mysql> CREATE TABLE t1 (
   id INT PRIMARY KEY AUTO_INCREMENT,
   name VARCHAR(100)
 ) ENGINE = InnoDB;

$> cd /path/to/mysql/data/test
$> ls
t1.ibd

3.2.3 File-Per-Table 表空间优点

详情见File-Per-Table Tablespace Advantages

3.2.4 File-Per-Table 表空间缺点

详情见File-Per-Table Tablespace Disadvantages

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值