MySQL tables space

Well my database is starting to get bigger and bigger. So I use this small query to know which table is consuming the more space.

1
2
3
4
5
6
SELECT
  concat(table_schema, '.', TABLE_NAME) AS "Tables",
  table_rows AS "# of Rows",
  round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;

Leave a Comment