Finding the largest MySQL tables

By Joel Stein on January 15, 2013

When dealing with large databases, it’s helpful to see some statistics about your tables. This is found in the “information_schema” database, under the “TABLES” table. Here’s a helpful query to find the size of all your tables in a particular database (the data size, index size, and total size), and sort by the total size.

SELECT TABLE_NAME `table`,
  CONCAT(ROUND(DATA_LENGTH / (1024 * 1024 * 1024), 2), ' GB') `data`,
  CONCAT(ROUND(INDEX_LENGTH / (1024 * 1024 * 1024), 2), ' GB') `index`,
  CONCAT(ROUND((DATA_LENGTH + INDEX_LENGTH) / (1024 * 1024 * 1024), 2), ' GB') `total`
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'my_database_name'
ORDER BY DATA_LENGTH + INDEX_LENGTH DESC

This was modified from this tip.