You can retrieve the index size for tables, partitions, or subpartitions can using the innodb_index_stats
table. In the following example, index sizes are retrieved for table t1
. For a definition of table t1
and corresponding index statistics, see Section 15.8.10.1.6, “InnoDB Persistent Statistics Tables Example”.
mysql>SELECT SUM(stat_value) pages, index_name,
SUM(stat_value)*@@innodb_page_size size
FROM mysql.innodb_index_stats WHERE table_name='t1'
AND stat_name = 'size' GROUP BY index_name;
+-------+------------+-------+ | pages | index_name | size | +-------+------------+-------+ | 1 | PRIMARY | 16384 | | 1 | i1 | 16384 | | 1 | i2uniq | 16384 | +-------+------------+-------+
For partitions or subpartitions, you can use the same query with a modified WHERE
clause to retrieve index sizes. For example, the following query retrieves index sizes for partitions of table t1
:
mysql>SELECT SUM(stat_value) pages, index_name,
SUM(stat_value)*@@innodb_page_size size
FROM mysql.innodb_index_stats WHERE table_name like 't1#P%'
AND stat_name = 'size' GROUP BY index_name;