一句话锁定MySQL数据占用元凶

简介

       背景:如今大量的MySQL服务迁移到云上了,因此当发生空间占用的时候,分析哪一个表占用较多就很麻烦,若是快速锁定元凶呢?数据库

方案

       一句话锁定元凶ide

select 
table_schema as '数据库名称',
sum(table_rows) as '记录总数',
sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;

提取出来的数据一目了然,好好看看如何修理大表吧!code

相关文章
相关标签/搜索