A tablespace consists of multiple files and/or raw disk partitions.
也可设置成独享表空间，每个表的数据和索引存放在一个单独的.ibd文件中，该文件包括每个表的表数据，索引数据和事务undo数据) file_name:file_size[:autoextend[:max:max_file_size]] • A file/partition is a collection of segments. • A segment consists of fixed-length pages. • The page size is always 16KB in uncompressed tablespaces, and 1KB-16KB in compressed tablespaces (for both data and index).
from:《InnoDB Internals: InnoDB File Formats and Source Code Structure》
22.214.171.124. File Space Management
The data files that you define in the configuration file form the
InnoDB tablespace. The files （innodb_data_file_path=ibdata1:1G;ibdata2:1G;ibdata3:1G;ibdata4:1G;ibdata5:1G ）are logically concatenated to form the tablespace. There is no striping in use. Currently, you cannot define where within the tablespace your tables are allocated. However, in a newly created tablespace,
InnoDB allocates space starting from the first data file.
The tablespace consists of database pages with a default size of 16KB. The pages are grouped into extents of size 1MB (64 consecutive pages). The “files” inside a tablespace are called segments in
InnoDB. The term “rollback segment” is somewhat confusing because it actually contains many tablespace segments.
When a segment grows inside the tablespace,
InnoDB allocates the first 32 pages to it individually. After that,
InnoDB starts to allocate whole extents to the segment.
InnoDB can add up to 4 extents at a time to a large segment to ensure good sequentiality of data.
Two segments are allocated for each index in
InnoDB. One is for nonleaf nodes of the B-tree, the other is for the leaf nodes. The idea here is to achieve better sequentiality for the leaf nodes, which contain the data.
Some pages in the tablespace contain bitmaps of other pages, and therefore a few extents in an
InnoDBtablespace cannot be allocated to segments as a whole, but only as individual pages.