Nick Henry

Just a site to share some of my memories.

Find the top 5 largest MySQL tables on your server

20 March 2012

SELECT
  CONCAT(table_schema, '.', table_name) AS tableName,
  CONCAT(ROUND(table_rows / 1000, 2), ' Thousand') AS numberOfRows,
  CONCAT(ROUND(data_length / ( 1024 * 1024 ), 2), ' MB') AS dataSize,
  CONCAT(ROUND(index_length / ( 1024 * 1024 ), 2), ' MB') AS indexSize,
  CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 ), 2), ' MB') AS totalSize,
  ROUND(index_length / data_length, 2) AS indexFraction
FROM information_schema.TABLES
ORDER  BY data_length + index_length DESC
LIMIT  5;

Read More