奇怪的知識(shí)增加了
查看索引樹的高度
查看索引的ROOT頁(yè)
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 |
+----------------------------------------+----------------------------+----------+------+-------+---------+
| mysql/engine_cost | PRIMARY | 41 | 3 | 23 | 3 |
| mysql/gtid_executed | PRIMARY | 37 | 3 | 18 | 3 |
...
+----------------------------------------+----------------------------+----------+------+-------+---------+
查看索引在.ibd文件中的偏移量
PAGE_LEVEL在每個(gè)頁(yè)的偏移量64位置處,占用兩個(gè)字節(jié)
# 查看engine_cost表的PRIMARY索引偏移位置
mysql> SELECT @@INNODB_PAGE_SIZE*3 + 64;
+---------------------------+
| @@INNODB_PAGE_SIZE*3 + 64 |
+---------------------------+
| 49216 |
+---------------------------+
1 row in set (0.00 sec)
使用hexdump工具查看文件內(nèi)容
[root@mysqltset mysql]# cd /data/mysql3306/data/mysql
[root@mysqltset mysql]# hexdump -s 49216 -n 10 -C engine_cost.ibd
0000c040 00 00 00 00 00 00 00 00 00 29 |.........)|
0000c04a
00 00 表示索引樹高度為1
相應(yīng)的
00 01 表示索引樹高度為2
00 02 表示索引樹高度為3
hexdump命令
hexdump主要用來查看“二進(jìn)制”文件的十六進(jìn)制編碼
它能夠查看任何文件次和,不限于二進(jìn)制文件
選項(xiàng)
- -n length:格式化輸出文件的前l(fā)ength個(gè)字節(jié)
- -C:輸出規(guī)范的十六進(jìn)制和ASCII碼
- -s:從偏移量開始輸出