List MySQL Table Space Consumption

How much space is MySQL consuming? How do I find out which MySQL tables are the largest? Can I query MySQL to determine how much space it’s consuming?

Try this to list the top 20 space offenders:

SELECT engine, concat( table_schema, '.', table_name ) table_name,
concat( round( data_length / ( 1024 *1024 ) , 2 ) , 'M' ) data_length,
concat( round( index_length / ( 1024 *1024 ) , 2 ) , 'M' ) index_length,
concat( round( round( data_length + index_length ) / ( 1024 *1024 ) , 2 ) , 'M' ) total_size
FROM information_schema.TABLES
ORDER BY ( ( data_length + index_length ) * 1 ) DESC LIMIT 20

Taken from a comment on the mysql developer docs site: http://dev.mysql.com/doc/refman/5.1/en/tables-table.html


Posted

in

, ,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *