[MySQL 운영]/MySQL Tip
DB별, Table별 데이터 사이즈
JJ*
2021. 1. 28. 15:31
DB별 데이터 사이즈 확인
select Table_Schema, round(sum(data_length/1024/1024),3) as `Data-Size (Mb)`, round(sum(index_length/1024/1024),3) as `Index-Size(Mb)`,
round(sum(data_length/1024/1024)+sum(index_length/1024/1024),3) as 'Total-Size(Mb)'
from information_schema.tables
where table_schema not in ('information_schema','dbstat','mysql','performance_schema','test')
group by Table_Schema
union all
select '---------------', '---------------', '---------------','---------------'
union all
select 'Total SUM', round(sum(data_length/1024/1024),1) as `Data-Size (Mb)`, round(sum(index_length/1024/1024),3) as `Index-Size(Mb)`,
round(sum(data_length/1024/1024)+sum(index_length/1024/1024),0) as 'Total-Size(Mb)'
from information_schema.tables
where table_schema not in ('information_schema','dbstat','mysql','performance_schema','test','sys');
select Table_Schema,
round(sum(data_length/1024/1024/1024)+sum(index_length/1024/1024/1024),0) as 'Total-Size(Gb)'
from information_schema.tables
where table_schema not in ('information_schema','dbstat','mysql','performance_schema','test')
group by Table_Schema
union all
select '---------------', '---------------'
union all
select 'Total SUM',
round(sum(data_length/1024/1024/1024)+sum(index_length/1024/1024/1024),0) as 'Total-Size(Gb)'
from information_schema.tables
where table_schema not in ('information_schema','dbstat','mysql','performance_schema','test');
Table별 데이터 사이즈 확인
select Table_Schema,table_name,
round(sum(data_length/1024/1024)+sum(index_length/1024/1024),0) as 'Total-Size(Mb)'
from information_schema.tables
where table_schema not in ('information_schema','dbstat','mysql','performance_schema','test','sys')
group by Table_Schema,table_name
union all
select '---------------', '---------------' ,'---------------'
union all
select 'Total SUM',table_name,
round(sum(data_length/1024/1024)+sum(index_length/1024/1024),0) as 'Total-Size(Mb)'
from information_schema.tables
where table_schema not in ('information_schema','dbstat','mysql','performance_schema','test','sys');