12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
mysql数据库 时间:2024-12-24 19:13:48
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
1. 背景 * 在InnoDB存储引擎中,表都是根据主键顺序组织存放的,这种存储方式的表称为索引组织表(index organized table IOT)。 * 在InnoDB存储引擎中,每张表都有个主键(Primary
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
1. 背景
* 在InnoDB存储引擎中,表都是根据主键顺序组织存放的,这种存储方式的表称为索引组织表(index organized table IOT)。
* 在InnoDB存储引擎中,每张表都有个主键(Primary key),如果在创建表时没有地定义主键,则InnoDB存储引擎会选择表中符合条件的列或隐式创建主键。
2. 环境
mysql>selectversion();+------------+|version()|+------------+|5.6.36-log|+------------+1rowinset(0.02sec)mysql>selectdatabase();+------------+|database()|+------------+|mytest|+------------+1rowinset(0.00sec)mysql>showtables;+------------------+|Tables_in_mytest|+------------------+|customer||district||history||item||new_orders||order_line||orders||stock||warehouse|+------------------+9rowsinset(0.00sec)mysql>showvariableslike'innodb_page_size';+------------------+-------+|Variable_name|Value|+------------------+-------+|innodb_page_size|8192|+------------------+-------+1rowinset(0.04sec)
3. 查询
* 查询每张表primary key对应的root page_no
mysql>selectt.table_idtable_id,t.nametable_name,i.page_noroot_page_nofrominformation_schema.INNODB_SYS_INDEXESi,information_schema.INNODB_SYS_TABLEStwherei.table_id=t.table_idandi.name='PRIMARY'andt.namelike'mytest/%';+----------+-------------------+--------------+|table_id|table_name|root_page_no|+----------+-------------------+--------------+|22|mytest/customer|3||21|mytest/district|3||27|mytest/item|3||24|mytest/new_orders|3||26|mytest/order_line|3||25|mytest/orders|3||28|mytest/stock|3||20|mytest/warehouse|3|+----------+-------------------+--------------+8rowsinset(0.04sec)
* 查询order_line表数据量
mysql>selectcount(1)fromorder_line;+----------+|count(1)|+----------+|6001615|+----------+1rowinset(9.03sec)
* 通过表数据文件order_line.ibd获取高度 [跳过 root_page_no * innodb_page_size + 64, 获取2字节长度就是树的高度]
由此可得树的高度为3, 高度标记从0开始
[root@localhostsrc]#hexdump-s24640-n2-C/data/mysql_data_6/mytest/order_line.ibd;000060400002|..|00006042
4. B+Tree
高度非叶节点数叶节点数数据行数占用空间10146816.0KiB211203> 563 thousand18.8MiB312041447209> 677 million22.1GiB414484131740992427> 814 billion25.9TiB5. xxx
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19