I want to determine the size of my indexes, they are primary key indexes. This happens to be on mysql cluster but I don’t think that is significant.
I think this is what you’re looking for.
show table status from [dbname]
If you are using InnoDB tables, you can get the size for individual indexes from
mysql.innodb_index_stats. The ‘size’ stat contains the answer, in pages, so you have to multiply it by the page-size, which is 16K by default.
select database_name, table_name, index_name, stat_value*@@innodb_page_size from mysql.innodb_index_stats where stat_name='size';
Extending Vajk Hermecz’s answer.
This is how you can get all of the indexes size, in megabytes, without the PRIMARY (which is the table itself), ordered by size.
SELECT database_name, table_name, index_name, round(stat_value*@@innodb_page_size/1024/1024, 2) size_in_mb FROM mysql.innodb_index_stats WHERE stat_name = 'size' AND index_name != 'PRIMARY' ORDER BY 4 DESC;
MyISAM, each index block is
4 KB page filled up to
fill_factor with index records, each being
key length + 4 bytes long.
Fill factor is normally
InnoDB, the table is always clustered on the
PRIMARY KEY, there is no separate
PRIMARY KEY index
Unused by me but perhaps MySQL Index Analyzer may be helpful.
Using phpMyAdmin, when viewing the table structure there is a Details link at the bottom somewhere. Once you click on it it will show you the total size of the indexes you have on the table where it is marked Space Usage.
I don’t think it shows you each index individually though.
In this article determine how to calculate index size.