MySQL table sizes

Some useful SQL for retrieving the size of individual MySQL tables.

Display table size for given table.

SELECT table_name AS "Table",
    ROUND(((data_length + index_length) / 1024 / 1024), 2) "Size in Mb"
FROM
    information_schema.TABLES
WHERE
    table_schema = "<DB_NAME>" AND
    table_name = "<DB_TABLE>";

Show ordered table sizes for given database.

SELECT table_name AS "Tables",
    ROUND(((data_length + index_length) / 1024 / 1024), 2) "Size in Mb"
FROM
    information_schema.TABLES
WHERE
    table_schema = "<DB_NAME>"
ORDER BY
    (data_length + index_length) DESC;
comments powered by Disqus