Wednesday, February 9, 2011

Mysql - to check respective MySQL table size in the specific database

SELECT table_name,
       concat(round(sum(table_rows)/1000000,2),'M') rows,
       concat(round(sum(data_length)/(1024*1024*1024),2),'G') data,
       concat(round(sum(index_length)/(1024*1024*1024),2),'G') idx,
       concat(round(sum(data_length+index_length)/(1024*1024*1024),2),'G') total_size,
       round(sum(index_length)/sum(data_length),2) idxfrac
       FROM information_schema.TABLES
WHERE table_schema = "<specific_database_name>"
group by table_name;



NOTES:
<specific_database_name> - replace this with your database name

No comments:

Post a Comment