参考连接:https://cloud.tencent.com/developer/article/1441324
https://www.jianshu.com/p/c51873ea129a
innodb_space 的git网址:https://github.com/jeremycole...
# yum -y install ruby # gem install innodb_ruby
安装完成后,执行如下命令验证innodb_ruby是否安装成功:# innodb_space --help
innodb_file_per_table=ON,innodb_file_format=Barracuda, innodb_file_format_max=Barracuda
Against a single space file (ibdata or .ibd): Option Parameters Description -fLoad the tablespace file (system or table) Against a system tablespace which will auto-load file-per-table tablespace files: Option Parameters Description -s Load the system tablespace file (e.g. ibdata1) -T Use the given table name. -I
Use the given index name 4.常用的用法
虽然每个innodb表都有frm文件,不过innodb在系统表空间中ibdata1也维护着innodb表的元数据,所以直接分析ibdata1文件即可了解某个表的相关存储信息 表结构:
CREATE TABLE `aa` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '地区ID', `name` varchar(20) NOT NULL DEFAULT '' COMMENT '名称', `rel_id` varchar(50) NOT NULL DEFAULT '' COMMENT '关系ID', `pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父ID', `level` int(11) NOT NULL DEFAULT '0' COMMENT '类别,1、省份 2、市 3、区 4、县', PRIMARY KEY (`id`), UNIQUE KEY `UNQ_RID` (`rel_id`) USING BTREE, KEY `IDX_PID` (`pid`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='地区表' 1 row in set (0.00 sec)表信息:
4.1 space 相关
4.1.1 system-spaces
innodb_space -s ibdata1 system-spaces //列出系统中可用的所有表空间,包括一些基本的统计信息。这基本上是一个表的列表: innodb_space -s ibdata1 system-spaces
[root@vm-test01 ztj]# innodb_space -s ../ibdata1 system-spaces name pages indexes (system) 4864 6 monitor/monitor 6 1 monitor/db_monitor 6 1 monitor/monitor 6 1 mysql/innodb_index_stats 6 1 mysql/innodb_table_stats 6 1 mysql/slave_master_info 6 1 mysql/slave_relay_log_info 6 1 mysql/slave_worker_info 6 1 opsdb/myapp_db_instance 8 1 test/aaa 6 1 test/area 8 3 ztj/aa 9 3 ztj/aaa 8 3 ztj/dim_library 4608 44.1.2 space-page-type-regions
//查看数据分布 innodb_space -s ibdata1 -T ztj/aa space-page-type-regions
[root@vm-test01 data]# innodb_space -s ibdata1 -T ztj/aa space-page-type-regions start end count type 0 0 1 FSP_HDR 1 1 1 IBUF_BITMAP 2 2 1 INODE 3 5 3 INDEX //索引分布在page:3/4/5,其中3保存Primary信息,4保存UNQ_RID信息,5保存IDX_PID信息 6 7 2 FREE (ALLOCATED)对于表的索引的名称,也可以通过information_schema库表innodb_sys_indexes、innodb_sys_tables查看:
mysql> SELECT -> b.name, a.name, index_id, type, a.space, a.PAGE_NO -> FROM -> information_schema.INNODB_SYS_INDEXES a, -> information_schema.INNODB_SYS_TABLES b -> WHERE -> a.table_id = b.table_id AND a.space <> 0; +------------------------------+-------------------------------------------+----------+------+-------+---------+ | name | name | index_id | type | space | PAGE_NO | +------------------------------+-------------------------------------------+----------+------+-------+---------+ | monitor/ll_monitor | GEN_CLUST_INDEX | 21 | 1 | 5 | 3 | | monitor/db_monitor | GEN_CLUST_INDEX | 22 | 1 | 6 | 3 | | monitor/monitor | GEN_CLUST_INDEX | 20 | 1 | 4 | 3 | | mysql/innodb_index_stats | PRIMARY | 23 | 3 | 7 | 3 | | mysql/innodb_table_stats | PRIMARY | 24 | 3 | 8 | 3 | | mysql/slave_master_info | PRIMARY | 25 | 3 | 9 | 3 | | mysql/slave_relay_log_info | PRIMARY | 26 | 3 | 10 | 3 | | mysql/slave_worker_info | PRIMARY | 47 | 3 | 18 | 3 | | ztj/aa | UNQ_RID | 51 | 2 | 19 | 4 | | ztj/aa | IDX_PID | 62 | 0 | 19 | 6 | | ztj/aaa | PRIMARY | 63 | 3 | 25 | 3 | | ztj/aaa | UNQ_RID | 64 | 2 | 25 | 4 | | ztj/aaa | IDX_PID | 65 | 0 | 25 | 5 | +------------------------------+-------------------------------------------+----------+------+-------+---------+4.1.3 space-indexes
//索引结构、数据分配情况 innodb_space -s ibdata1 -T ztj/aa space-indexes
[root@vm-test01 data]# innodb_space -s ibdata1 -T ztj/aa space-indexes id name root fseg used allocated fill_factor 50 PRIMARY 3 internal 1 1 100.00% 50 PRIMARY 3 leaf 0 0 0.00% 51 UNQ_RID 4 internal 1 1 100.00% 51 UNQ_RID 4 leaf 0 0 0.00% 52 IDX_PID 5 internal 1 1 100.00% 52 IDX_PID 5 leaf 0 0 0.00%4.1.4 space-page-type-summary
//查看表pages的占比 innodb_space -s ../ibdata1 -T ztj/aa space-page-type-summary
[root@vm-test01 ztj]# innodb_space -s ../ibdata1 -T ztj/aa space-page-type-summary type count percent description INDEX 3 37.50 B+Tree index ALLOCATED 2 25.00 Freshly allocated INODE 1 12.50 File segment inode IBUF_BITMAP 1 12.50 Insert buffer bitmap FSP_HDR 1 12.50 File space header4.1.5 space-index-pages-summary
//查看表的索引分布在pages的情况 innodb_space -s ibdata1 -T ztj/aaa space-index-pages-summar |head -n 10 innodb_space -f ztj/aaa.ibd space-index-pages-summary |head -n 10
[root@vm-test01 data]# innodb_space -s ibdata1 -T ztj/aaa space-index-pages-summary |head -n 10 page index level data free records 3 63 0 948 15298 16 //主键B+树的高度为page level+1=1 4 64 0 380 15866 16 5 65 0 208 16040 16 6 0 0 0 16384 0 7 0 0 0 16384 0 [root@vm-test01 ztj]# innodb_space -f dim_library.ibd space-index-pages-summary |head -n 10 page index level data free records 3 28 2 45 16207 3 //主键B+树索引的高度为page level+1=3 4 29 1 8470 7598 385 5 30 1 11487 4575 547 6 31 1 7980 8122 380 7 28 0 7526 8690 72 8 28 0 15137 1045 144 9 28 0 15074 1108 144 10 28 0 15110 1072 144 11 28 0 15104 1080 1434.2 page 相关
4.2.1 page-account
//查看该page的说明信息
[root@vm-test01 ztj]# innodb_space -s ../ibdata1 -T ztj/aa -p 3 page-account Accounting for page 3: Page type is INDEX (B+Tree index, table and index data stored in B+Tree structure). Extent descriptor for pages 0-63 is at page 0, offset 158. Extent is not fully allocated to an fseg; may be a fragment extent. Page is marked as used in extent descriptor. Extent is in free_frag list of space. Page is in fragment array of fseg 1. Fseg is in internal fseg of index 63. Index root is page 3. Index is ztj /aa.PRIMARY. [root@vm-test01 ztj]# [root@vm-test01 ztj]# innodb_space -s ../ibdata1 -T ztj/aa -p 4 page-account Accounting for page 4: Page type is INDEX (B+Tree index, table and index data stored in B+Tree structure). Extent descriptor for pages 0-63 is at page 0, offset 158. Extent is not fully allocated to an fseg; may be a fragment extent. Page is marked as used in extent descriptor. Extent is in free_frag list of space. Page is in fragment array of fseg 3. Fseg is in internal fseg of index 64. Index root is page 4. Index is ztj/aa.UNQ_RID.4.2.2 page-records
//查看辅助索引存储信息 innodb_space -s ibdata1 -T ztj/aa -p 4 page-records
[root@vm-test01 data]# innodb_space -s ibdata1 -T ztj/aa -p 4 page-records Record 126: (rel_id="10000") → (id=10000) Record 141: (rel_id="1000010001") → (id=10001) Record 161: (rel_id="100001000110002") → (id=10002) Record 186: (rel_id="100001000110003") → (id=10003) Record 211: (rel_id="100001000110004") → (id=10004) Record 236: (rel_id="100001000110005") → (id=10005) Record 261: (rel_id="100001000110006") → (id=10006) Record 286: (rel_id="100001000110007") → (id=10007) Record 311: (rel_id="100001000110008") → (id=10008) Record 336: (rel_id="1000010009") → (id=10009) Record 356: (rel_id="100001000910010") → (id=10010) Record 381: (rel_id="100001000910011") → (id=10011) Record 406: (rel_id="100001000910012") → (id=10012) Record 431: (rel_id="100001000910013") → (id=10013) Record 456: (rel_id="100001000910014") → (id=10014) Record 481: (rel_id="100001000910015") → (id=10015) innodb_space -s ibdata1 -T ztj/aa -p 5 page-records [root@vm-test01 data]# innodb_space -s ibdata1 -T ztj/aa -p 5 page-records Record 125: (pid=0) → (id=10000) Record 138: (pid=10000) → (id=10001) Record 151: (pid=10000) → (id=10009) Record 164: (pid=10001) → (id=10002) Record 177: (pid=10001) → (id=10003) Record 190: (pid=10001) → (id=10004) Record 203: (pid=10001) → (id=10005) Record 216: (pid=10001) → (id=10006) Record 229: (pid=10001) → (id=10007) Record 242: (pid=10001) → (id=10008) Record 255: (pid=10009) → (id=10010) Record 268: (pid=10009) → (id=10011) Record 281: (pid=10009) → (id=10012) Record 294: (pid=10009) → (id=10013) Record 307: (pid=10009) → (id=10014) Record 320: (pid=10009) → (id=10015)4.2.3 page-records
//主键索引的存储信息 innodb_space -s ibdata1 -T ztj/aa -p 3 page-records
[root@vm-test01 data]# innodb_space -s ibdata1 -T ztj/aa -p 3 page-records Record 127: (id=10000) → (name="\xE5\x8C\x97\xE4\xBA\xAC", rel_id="10000", pid=0, level=1) Record 170: (id=10001) → (name="\xE6\x9C\x9D\xE9\x98\xB3\xE5\x8C\xBA", rel_id="1000010001", pid=10000, level=2) Record 221: (id=10002) → (name="\xE4\xB8\x89\xE7\x8E\xAF\xE4\xBB\xA5\xE5\x86\x85", rel_id="100001000110002", pid=10001, level=3) Record 280: (id=10003) → (name="\xE4\xB8\x89\xE7\x8E\xAF\xE5\x88\xB0\xE5\x9B\x9B\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000110003", pid=10001, level=3) Record 348: (id=10004) → (name="\xE5\x9B\x9B\xE7\x8E\xAF\xE5\x88\xB0\xE4\xBA\x94\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000110004", pid=10001, level=3) Record 416: (id=10005) → (name="\xE4\xBA\x94\xE7\x8E\xAF\xE5\x88\xB0\xE5\x85\xAD\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000110005", pid=10001, level=3) Record 484: (id=10006) → (name="\xE7\xAE\xA1\xE5\xBA\x84", rel_id="100001000110006", pid=10001, level=3) Record 537: (id=10007) → (name="\xE5\x8C\x97\xE8\x8B\x91", rel_id="100001000110007", pid=10001, level=3) Record 590: (id=10008) → (name="\xE5\xAE\x9A\xE7\xA6\x8F\xE5\xBA\x84", rel_id="100001000110008", pid=10001, level=3) Record 646: (id=10009) → (name="\xE6\xB5\xB7\xE6\xB7\x80\xE5\x8C\xBA", rel_id="1000010009", pid=10000, level=2) Record 697: (id=10010) → (name="\xE4\xB8\x89\xE7\x8E\xAF\xE4\xBB\xA5\xE5\x86\x85", rel_id="100001000910010", pid=10009, level=3) Record 756: (id=10011) → (name="\xE4\xB8\x89\xE7\x8E\xAF\xE5\x88\xB0\xE5\x9B\x9B\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000910011", pid=10009, level=3) Record 824: (id=10012) → (name="\xE5\x9B\x9B\xE7\x8E\xAF\xE5\x88\xB0\xE4\xBA\x94\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000910012", pid=10009, level=3) Record 892: (id=10013) → (name="\xE4\xBA\x94\xE7\x8E\xAF\xE5\x88\xB0\xE5\x85\xAD\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000910013", pid=10009, level=3) Record 960: (id=10014) → (name="\xE5\x85\xAD\xE7\x8E\xAF\xE4\xBB\xA5\xE5\xA4\x96", rel_id="100001000910014", pid=10009, level=3) Record 1019: (id=10015) → (name="\xE8\xA5\xBF\xE4\xB8\x89\xE6\x97\x97", rel_id="100001000910015", pid=10009, level=3)结论:辅助索引存储了主键值。主键page存储了所有数据
4.3 index相关
4.3.1 index-recurse
//递归整个B+树,扫描所有页面 innodb_space -s ../ibdata1 -T ztj/aaa -I PRIMARY index-recurse
[root@vm-test01 ztj]# innodb_space -s ../ibdata1 -T ztj/aaa -I PRIMARY index-recurse ROOT NODE #3: 16 records, 948 bytes RECORD: (id=10000) → (name="\xE5\x8C\x97\xE4\xBA\xAC", rel_id="10000", pid=0, level=1) RECORD: (id=10001) → (name="\xE6\x9C\x9D\xE9\x98\xB3\xE5\x8C\xBA", rel_id="1000010001", pid=10000, level=2) RECORD: (id=10002) → (name="\xE4\xB8\x89\xE7\x8E\xAF\xE4\xBB\xA5\xE5\x86\x85", rel_id="100001000110002", pid=10001, level=3) RECORD: (id=10003) → (name="\xE4\xB8\x89\xE7\x8E\xAF\xE5\x88\xB0\xE5\x9B\x9B\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000110003", pid=10001, level=3) RECORD: (id=10004) → (name="\xE5\x9B\x9B\xE7\x8E\xAF\xE5\x88\xB0\xE4\xBA\x94\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000110004", pid=10001, level=3) RECORD: (id=10005) → (name="\xE4\xBA\x94\xE7\x8E\xAF\xE5\x88\xB0\xE5\x85\xAD\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000110005", pid=10001, level=3) RECORD: (id=10006) → (name="\xE7\xAE\xA1\xE5\xBA\x84", rel_id="100001000110006", pid=10001, level=3) RECORD: (id=10007) → (name="\xE5\x8C\x97\xE8\x8B\x91", rel_id="100001000110007", pid=10001, level=3) RECORD: (id=10008) → (name="\xE5\xAE\x9A\xE7\xA6\x8F\xE5\xBA\x84", rel_id="100001000110008", pid=10001, level=3) RECORD: (id=10009) → (name="\xE6\xB5\xB7\xE6\xB7\x80\xE5\x8C\xBA", rel_id="1000010009", pid=10000, level=2) RECORD: (id=10010) → (name="\xE4\xB8\x89\xE7\x8E\xAF\xE4\xBB\xA5\xE5\x86\x85", rel_id="100001000910010", pid=10009, level=3) RECORD: (id=10011) → (name="\xE4\xB8\x89\xE7\x8E\xAF\xE5\x88\xB0\xE5\x9B\x9B\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000910011", pid=10009, level=3) RECORD: (id=10012) → (name="\xE5\x9B\x9B\xE7\x8E\xAF\xE5\x88\xB0\xE4\xBA\x94\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000910012", pid=10009, level=3) RECORD: (id=10013) → (name="\xE4\xBA\x94\xE7\x8E\xAF\xE5\x88\xB0\xE5\x85\xAD\xE7\x8E\xAF\xE4\xB9\x8B\xE9\x97\xB4", rel_id="100001000910013", pid=10009, level=3) RECORD: (id=10014) → (name="\xE5\x85\xAD\xE7\x8E\xAF\xE4\xBB\xA5\xE5\xA4\x96", rel_id="100001000910014", pid=10009, level=3) RECORD: (id=10015) → (name="\xE8\xA5\xBF\xE4\xB8\x89\xE6\x97\x97", rel_id="100001000910015", pid=10009, level=3)4.3.2 index-record-offsets
//像index-record一样递归整个索引树,不过只打印出index page的偏移量 innodb_space -s ../ibdata1 -T ztj/aaa -I PRIMARY index-record-offsets
[root@vm-test01 ztj]# innodb_space -s ../ibdata1 -T ztj/aaa -I PRIMARY index-record-offsets page_offset record_offset 3 127 3 170 3 221 3 280 3 348 3 416 3 484 3 537 3 590 3 646 3 697 3 756 3 824 3 892 3 960 3 10194.4 record相关
4.4.1 record-history
//递归整个B+树,扫描所有页面 innodb_space -s ../ibdata1 -T ztj/aaa -I PRIMARY index-recurse
[root@vm-test01 ztj]# innodb_space -s ../ibdata1 -T ztj/aaa -I PRIMARY -p 3 -R 127 record-history Transaction Type Undo record (n/a) insert (id=10000) → ()5、索引是物理有序的还是逻辑有序的?
page内的数据:逻辑上有序的,物理磁盘上⼀个page内是⽆序的,以指针的形式连接 数据,达到逻辑有序 【正常1, 2, 3, 4, 5. 存储是:1, 3 ,2, 5, 4。1链接2链接3链 接4链接5】⻚和⻚之间也是:逻辑上有序,物理上⽆序。 ⾃增ID,逻辑上也是有序 的。
解读InnoDB页面--索引结构
简介: 前言 很久之前了解到innodb_space,觉得很强大,可视化了InnoDB页面,但是没有形成文档,总结出来,有一些经常被问到的东东可以用这个查看了。 环境 centos 7 Linux izhp3j8nb7nyq2g923r9fvz 3.
前言
很久之前了解到innodb_space,觉得很强大,可视化了InnoDB页面,但是没有形成文档,总结出来,有一些经常被问到的东东可以用这个查看了。
环境
centos 7 Linux 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux Server version: 5.7.20 MySQL Community Server (GPL)
安装
sudo yum install rubygems ruby-devel sudo gem install innodb_ruby
解读
总述
选项
- -f 加载表空间,如ibd文件
- -s 加载系统表空间,如ibd
- -T 指定表名
- -I 指定索引名
继续拿这个表做例子:
mysql> show create table sbtest1\G *************************** 1. row *************************** Table: sbtest1 Create Table: CREATE TABLE `sbtest1` ( `id` int(11) NOT NULL AUTO_INCREMENT, `gmt_create` datetime NOT NULL, `gmt_modified` datetime NOT NULL, `k` int(11) NOT NULL DEFAULT '0', `c` varchar(500) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', `is_used` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `k_1` (`k`), KEY `idx_is_used` (`is_used`), KEY `idx_gmt_create` (`gmt_create`) ) ENGINE=InnoDB AUTO_INCREMENT=69313841 DEFAULT CHARSET=latin1 1 row in set (0.00 sec)
索引结构
index-recurse
[root@localhost mysql]# innodb_space -s ibdata1 -T test/sbtest1 -I PRIMARY index-recurse | more ROOT NODE #3: 369 records, 5166 bytes NODE POINTER RECORD ≥ (id=43000569) → #9 INTERNAL NODE #9: 1050 records, 14700 bytes NODE POINTER RECORD ≥ (id=43000569) → #7 LEAF NODE #7: 68 records, 15028 bytes RECORD: (id=43000569) → (gmt_create="184616470-38-96 24:80:37", gmt_modified="-891360229-11-75 00:49:77", k=-1271582413, c="73586-15688153734-79729593694-96509299839-83724898275-8671183 3539-78981337422-35049690573-51724173961-87474696253989966", pad="21624-36689827414-04092488557-09587706818-65008859162 \x80\x00\x00\x00w\x00", is_used=-2147477504) RECORD: (id=43000570) → (gmt_create="184616470-38-96 24:80:37", gmt_modified="-891360231-94-84 49:64:33", k=-1271451079, c="70079-70972780322-70018558993-71769650003-09270326047-3241701 2031-10768856803-14235120402-93989080412-18690312264047768", pad="26683-45880822084-77922711547-29057964468-76514263618 \x80\x00\x00\x00w\x00", is_used=-2147475456) RECORD: (id=43000571) → (gmt_create="184616470-38-96 24:80:37", gmt_modified="-891360229-49-27 20:33:85", k=-1288227272, c="27441-24903985029-56844662308-79012577859-40518387141-6058841 9212-24399130405-42612257832-29494881732-71506024440268430", pad="35807-96849339132-53943793991-69741192222-48634174017 \x80\x00\x00\x00w\x00", is_used=-2080364544) ...
index-record-offsets
[root@localhost mysql]# innodb_space -s ibdata1 -T test/sbtest1 -I PRIMARY index-record-offsets | more page_offset record_offset 7 127 7 348 7 569 7 790 7 1011 7 1232 7 1453 7 1674 7 1895 7 2116 ...
index-level-summary
[root@localhost mysql]# innodb_space -s ibdata1 -T test/sbtest1 -I PRIMARY -l 0 index-level-summary | more page index level data free records min_key 7 74 0 15028 1192 68 id=43000569 8 74 0 15028 1192 68 id=43000637 10 74 0 15028 1192 68 id=43000705 11 74 0 15028 1192 68 id=43000773 12 74 0 15028 1192 68 id=43000841 13 74 0 15028 1192 68 id=43000909 14 74 0 15028 1192 68 id=43000977 15 74 0 15028 1192 68 id=43001045 16 74 0 15028 1192 68 id=43001113 17 74 0 15028 1192 68 id=43001181 18 74 0 15028 1192 68 id=43001249 19 74 0 15028 1192 68 id=43001317 ...
记录结构
record-dump
[root@localhost mysql]# innodb_space -s ibdata1 -T test/sbtest1 -p 7 -R 128 record-dump Record at offset 128 Header: Next record offset : -8702 Heap number : 512 Type : conventional Deleted : false Length : 7 System fields: Transaction ID: 38377940 Roll Pointer: Undo Log: page 112897, offset 4249 Rollback Segment ID: 0 Insert: false Key fields: id: 270727424 Non-key fields: gmt_create: "222619031-78-45 93:12:68" gmt_modified: "-370929284-39-30 89:87:40" k: -1255066825 c: "" pad: "3586-15688153734-79729593694-96509299839-83724898275-8671183" is_used: -1288359111
记录历史
record-history
[root@localhost mysql]# innodb_space -s ibdata1 -T test/sbtest1 -p 7 -R 128 record-history Transaction Type Undo record [root@localhost mysql]#
其他拓展
space-lists
[root@localhost mysql]# innodb_space -s ibdata1 space-lists name length f_page f_offset l_page l_offset free 619 32768 6918 0 438 free_frag 5 0 398 0 318 full_frag 2 0 158 0 278 full_inodes 1 2 38 2 38 free_inodes 2 322 38 243 38 [root@localhost mysql]#
space-list-iterate
[root@localhost mysql]# innodb_space -s ibdata1 space-list-iterate -L free_frag start_page page_used_bitmap 384 #############........###################################........ 16384 ##.............................................................. 32768 ##.............................................................. 320 ####################################################.######.##.. 256 #############################.##.#..##...###..#.######..####.##. [root@localhost mysql]#
space-inodes-summary
[root@localhost mysql]# innodb_space -s ibdata1 space-inodes-summary INODE fseg_id=1, pages=3552, frag=32, full=47, not_full=8, free=0 INODE fseg_id=2, pages=1, frag=1, full=0, not_full=0, free=0 INODE fseg_id=3, pages=1, frag=1, full=0, not_full=0, free=0 INODE fseg_id=4, pages=1, frag=1, full=0, not_full=0, free=0 INODE fseg_id=5, pages=1, frag=1, full=0, not_full=0, free=0 INODE fseg_id=6, pages=0, frag=0, full=0, not_full=0, free=0 INODE fseg_id=7, pages=1, frag=1, full=0, not_full=0, free=0 INODE fseg_id=8, pages=0, frag=0, full=0, not_full=0, free=0 INODE fseg_id=9, pages=1, frag=1, full=0, not_full=0, free=0 INODE fseg_id=10, pages=0, frag=0, full=0, not_full=0, free=0 INODE fseg_id=11, pages=1, frag=1, full=0, not_full=0, free=0 INODE fseg_id=12, pages=0, frag=0, full=0, not_full=0, free=0 INODE fseg_id=13, pages=1, frag=1, full=0, not_full=0, free=0 INODE fseg_id=14, pages=0, frag=0, full=0, not_full=0, free=0 INODE fseg_id=15, pages=160, frag=32, full=2, not_full=0, free=0 INODE fseg_id=16, pages=1, frag=1, full=0, not_full=0, free=0 ...
undo-history-summary
[root@izhp3j8nb7nyq2g923r9fvz mysql]# innodb_space -s ibdata1 undo-history-summary Page Offset Transaction Type Table 345 2452 162569 delete 345 2512 162600 delete 345 2598 162601 update_deleted 345 2675 162569 update_existing SYS_TABLESPACES 345 2716 162569 update_existing SYS_DATAFILES 345 2763 162600 update_existing SYS_TABLESPACES 345 2817 162600 update_existing SYS_DATAFILES 347 2859 162595 delete mysql/innodb_table_stats 284 2925 162581 delete mysql/innodb_index_stats 284 3020 162581 delete mysql/innodb_index_stats 284 3115 162581 delete mysql/innodb_index_stats 284 3194 162597 delete mysql/innodb_index_stats 284 3303 162597 delete mysql/innodb_index_stats 284 3412 162597 delete mysql/innodb_index_stats 284 3521 162597 delete mysql/innodb_index_stats 284 3614 162589 delete mysql/innodb_index_stats 284 3717 162589 delete mysql/innodb_index_stats 284 3820 162589 delete mysql/innodb_index_stats 284 3923 162589 delete mysql/innodb_index_stats 284 4010 162581 delete mysql/innodb_index_stats 284 4097 162581 delete mysql/innodb_index_stats 284 4184 162581 delete mysql/innodb_index_stats 284 4271 162581 delete mysql/innodb_index_stats 312 3626 162568 delete 312 3679 162568 delete 312 3740 162568 delete ...
undo-record-dump
Print a detailed description of an undo record and the data it contains:
[root@localhost mysql]# innodb_space -s ibdata1 -p page -R offset undo-record-dump /usr/local/share/gems/gems/innodb_ruby-0.9.15/bin/innodb_space:1582:in `undo_record_dump': undefined method `root' for nil:NilClass (NoMethodError) from /usr/local/share/gems/gems/innodb_ruby-0.9.15/bin/innodb_space:2055:in `
' from /usr/local/bin/innodb_space:23:in `load' from /usr/local/bin/innodb_space:23:in ` ' 引用ruby库
$ irb -r innodb > sys = Innodb::System.new("ibdata1") > idx = sys.index_by_name("sakila/film", "PRIMARY") > rec = idx.binary_search([1])
参考
https://github.com/jeremycole/innodb_ruby/wiki
开发原理
https://blog.jcole.us/2013/01/10/btree-index-structures-in-innodb/
你可能感兴趣的:(#,MySQL)