索引的
mysql> show indexes from recordsInRangeTest; +--------------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +--------------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | recordsInRangeTest | 0 | PRIMARY | 1 | id | A | 24290 | NULL | NULL | | BTREE | | | | recordsInRangeTest | 1 | idx_name | 1 | name | A | 12 | NULL | NULL | YES | BTREE | | | | recordsInRangeTest | 1 | idx_age | 1 | age | A | 12 | NULL | NULL | YES | BTREE | | | | recordsInRangeTest | 1 | idx_age_name | 1 | name | A | 12 | NULL | NULL | YES | BTREE | | | | recordsInRangeTest | 1 | idx_age_name | 2 | age | A | 22 | NULL | NULL | YES | BTREE | | | +--------------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ 5 rows in set (0.00 sec)
select * from innodb_index_stats where table_name='recordsInRangeTest';
+---------------+--------------------+--------------+---------------------+--------------+------------+-------------+-----------------------------------+ | database_name | table_name | index_name | last_update | stat_name | stat_value | sample_size | stat_description | +---------------+--------------------+--------------+---------------------+--------------+------------+-------------+-----------------------------------+ | test | recordsInRangeTest | PRIMARY | 2018-07-17 05:02:50 | n_diff_pfx01 | 24290 | 20 | id | | test | recordsInRangeTest | PRIMARY | 2018-07-17 05:02:50 | n_leaf_pages | 55 | NULL | Number of leaf pages in the index | | test | recordsInRangeTest | PRIMARY | 2018-07-17 05:02:50 | size | 97 | NULL | Number of pages in the index | | test | recordsInRangeTest | idx_age | 2018-07-17 05:02:50 | n_diff_pfx01 | 6 | 29 | age | | test | recordsInRangeTest | idx_age | 2018-07-17 05:02:50 | n_diff_pfx02 | 24576 | 29 | age,id | | test | recordsInRangeTest | idx_age | 2018-07-17 05:02:50 | n_leaf_pages | 29 | NULL | Number of leaf pages in the index | | test | recordsInRangeTest | idx_age | 2018-07-17 05:02:50 | size | 30 | NULL | Number of pages in the index | | test | recordsInRangeTest | idx_age_name | 2018-07-17 05:02:50 | n_diff_pfx01 | 6 | 29 | name | | test | recordsInRangeTest | idx_age_name | 2018-07-17 05:02:50 | n_diff_pfx02 | 11 | 29 | name,age | | test | recordsInRangeTest | idx_age_name | 2018-07-17 05:02:50 | n_diff_pfx03 | 24576 | 29 | name,age,id | | test | recordsInRangeTest | idx_age_name | 2018-07-17 05:02:50 | n_leaf_pages | 29 | NULL | Number of leaf pages in the index | | test | recordsInRangeTest | idx_age_name | 2018-07-17 05:02:50 | size | 30 | NULL | Number of pages in the index | | test | recordsInRangeTest | idx_name | 2018-07-17 05:02:50 | n_diff_pfx01 | 6 | 24 | name | | test | recordsInRangeTest | idx_name | 2018-07-17 05:02:50 | n_diff_pfx02 | 24576 | 24 | name,id | | test | recordsInRangeTest | idx_name | 2018-07-17 05:02:50 | n_leaf_pages | 24 | NULL | Number of leaf pages in the index | | test | recordsInRangeTest | idx_name | 2018-07-17 05:02:50 | size | 25 | NULL | Number of pages in the index | +---------------+--------------------+--------------+---------------------+--------------+------------+-------------+-----------------------------------+
表本身的
+--------------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+---------+ | Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | +--------------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+---------+ | recordsInRangeTest | InnoDB | 10 | Compact | 24290 | 65 | 1589248 | 0 | 1425408 | 4194304 | 28660 | 2018-06-09 09:29:26 | NULL | NULL | latin1_swedish_ci | NULL | | | +--------------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+---------+