mysql查看索引大小和重建索引

查看索引大小:

use information_schema;
select
concat(round(sum(index_LENGTH)/(1024*1024),2),'MB') as 'Index Size(MB)',
index_LENGTH as 'Index Size(Bytes)'
from tables
where table_schema='my_db' and table_name='table_name';


重建索引(MyISAM下面语句有效;innodb下面语句无效,需要先删除索引,然后重建):

use my_db;
REPAIR TABLE table_name QUICK;

你可能感兴趣的:(mysql查看索引大小和重建索引)