总体结构
数据文件(space file)
图来源于https://github.com/jeremycole/innodb_diagrams page 0,1,3 是预留的page
page0 FSP_HDR 描叙tablespace的基本信息和extend的基本信息
page1 insert buffer bitmap的基本信息
page2 是inode page
page3 index page 真实的数据信息
每256M都会有一个XDES
页(page)
file header (38)
[root@dba-test-02 inno_space-main]
File path /data/mysql3307/data/musk/xxx.ibd path, page num 4
==========================block==========================
FIL Header:
CheckSum: 2426195884
Page number: 4
Previous Page: 4294967295
Next Page: 5
Page LSN: 23747813612
Page Type: 17855
Flush LSN: 0
index header(36)
Index Header
Number of Directory Slots: 46
Garbage Space: 0
Number of Records: 181
Max Trx id: 0
Page level: 0
Index ID: 245
FSEG header(20) segment的基本信息
system Records(26)
User Records
页里面的基本存储结构 infimum 逻辑的第一条记录;物理上的第一条记录 supremum 逻辑的最后一条记录; 物理上的第二条记录
测试: mysql> create table t(i int not null, s char(10) not null,primary key(i)); Query OK, 0 rows affected (0.01 sec)
mysql> insert into t (i,s) values(1,‘A’),(1,‘B’),(2,‘C’); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0
使用innlock:https://github.com/gaopengcarl/innblock
[root@dba-test-02 innblock-master]
----------------------------------------------------------------------------------------------------
Welcome to use this block analyze tool:
[Author]:gaopeng [Blog]:blog.itpub.net/7728585/abstract/1/ [QQ]:22389860
[Review]:yejinrong@zhishutang [Blog]:imysql.com [QQ]:4700963
----------------------------------------------------------------------------------------------------
==== Block base info ====
block_no:3 space_id:190 index_id:246
slot_nums:2 heaps_rows:5 n_rows:3
heap_top:219 del_bytes:0 last_ins_offset:192
page_dir:2 page_n_dir:2
leaf_inode_space:190 leaf_inode_pag_no:2
leaf_inode_offset:242
no_leaf_inode_space:190 no_leaf_inode_pag_no:2
no_leaf_inode_offset:50
last_modify_lsn:23747828697
page_type:B+_TREE level:0
==== Block list info ====
-----Total used rows:5 used rows list(logic):
(1) INFIMUM record offset:99 heapno:0 n_owned 1,delflag:N minflag:0 rectype:2
(2) normal record offset:126 heapno:2 n_owned 0,delflag:N minflag:0 rectype:0
(3) normal record offset:159 heapno:3 n_owned 0,delflag:N minflag:0 rectype:0
(4) normal record offset:192 heapno:4 n_owned 0,delflag:N minflag:0 rectype:0
(5) SUPREMUM record offset:112 heapno:1 n_owned 4,delflag:N minflag:0 rectype:3
-----Total used rows:5 used rows list(phy):
(1) INFIMUM record offset:99 heapno:0 n_owned 1,delflag:N minflag:0 rectype:2
(2) SUPREMUM record offset:112 heapno:1 n_owned 4,delflag:N minflag:0 rectype:3
(3) normal record offset:126 heapno:2 n_owned 0,delflag:N minflag:0 rectype:0
(4) normal record offset:159 heapno:3 n_owned 0,delflag:N minflag:0 rectype:0
(5) normal record offset:192 heapno:4 n_owned 0,delflag:N minflag:0 rectype:0
-----Total del rows:0 del rows list(logic):
-----Total slot:2 slot list:
(1) SUPREMUM slot offset:112 n_owned:4
(2) INFIMUM slot offset:99 n_owned:1
详细的解释:http://blog.itpub.net/7728585/viewspace-2145616/
使用inno对比:
[root@dba-test-02 inno_space-main]
File path /data/mysql3307/data/musk/t.ibd path, page num 3
==========================block==========================
FIL Header:
CheckSum: 984458749
Page number: 3
Previous Page: 4294967295
Next Page: 4294967295
Page LSN: 23747828697
Page Type: 17855
Flush LSN: 0
Index Header
Number of Directory Slots: 2
Garbage Space: 0
Number of Records: 3
Max Trx id: 0
Page level: 0
Index ID: 246
infimum 99
supremum 112
heap no 0
rec status 2
heap no 2
rec status 0
heap no 3
rec status 0
heap no 4
rec status 0
heap no 1
rec status 3
Free space
Page directory
slot list,管理对应的数据,同上面的o_owner -----Total slot:2 slot list 上面的page directory的一个数组记录了每个slot的偏移量
file trailer(8)
同header ,主要进行checksum
行长度的计算:
可以看到第一行记录的:33B 计算如下: 固定长度头的6B = 2=1B +1B(1 char field) ((4+4)/8)+ ((13+3)/8) 为空的bitmap 1B 上面见的表有两个可为null的字段,故 需要1bits ,使用一个大B 可变长度 2B 每个可变长度至少1B,如果超过255字节,则需要2B 主键: 4B int类型 4B db_trx_id. 6B db_roll_ptr. 7B
6(header) + 6(db_trx_id) + 7(db_roll_ptr) +(4)+(10) =33 发现和上图的不一致,不知道为什么,版本的差异??
|