考慮表結構如下: 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是符號位)