考虑表结构如下: create table testzh(id int primary key auto_increment ,id2 int,id3 int); 插入数据: delimiter // create procedure ins3() begin declare i int; set i=0; while i<10000 do insert into testzh(id2,id3) values(FLOOR((RAND()*100000)),FLOOR((RAND()*100000))); set i=i+1; end while; end; // delimiter ;
位了找到这个问题我们必须要找到哪些块是叶子结点,哪些块是非叶子结点,这里使用自己写的一个程序 找到详细参考最后的代码 (http://blog.itpub.net/7728585/viewspace-2128817/) [root@testmy test]# ./t1 testzh.ibd file size is 442368 Block id is 3:Index page no is 552 : B+ Tree Level is 1 Block id is 4:Index page no is 552 : B+ Tree Level is 0 Block id is 5:Index page no is 552 : B+ Tree Level is 0 Block id is 6:Index page no is 552 : B+ Tree Level is 0 Block id is 7:Index page no is 552 : B+ Tree Level is 0 Block id is 8:Index page no is 552 : B+ Tree Level is 0 Block id is 9:Index page no is 552 : B+ Tree Level is 0 .....
固定开销(6字节) 00 nullable field bitmap (?) 10 info flags+number of records owned 0011 order+ record type (0000 0000 0001 0001) 000e 下一个偏移量 --可变开销(实际数据4字节) 80000001 (实际主键数据1其中8是符号位) --固定开销(4字节) 00000004 (叶子结点block指针) 我们可以看到这是非叶子结点存储数据的格式如此,除了4字节的主键外,这里包含了10字节的额外开销。
00 nullable field bitmap(?) 00 info flags+number of records owned 0010 order+record type 001f 下一个偏移量 80000001 (实际主键id数据1其中8是符号位) 0000004d1995 transaction id cd000001440110 roll pointer 800046cd (实际数据id2:18125 8是符号位) 80000683 (实际数据id2:1667 8是符号位)