DeveloperBreeze

Storage Planning Development Tutorials, Guides & Insights

Unlock 1+ expert-curated storage planning tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your storage planning skills on DeveloperBreeze.

Viewing the Database Size and Identifying the Largest Table in MySQL

Tutorial August 12, 2024
mysql

SELECT table_name AS "Table",
       ROUND((data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"
FROM information_schema.tables
WHERE table_schema = 'your_database_name'
ORDER BY (data_length + index_length) DESC
LIMIT 1;
  • table_name: The name of each table in the specified database.
  • ORDER BY (data_length + index_length) DESC: Orders the tables by size in descending order, so the largest appears first.
  • LIMIT 1: Limits the result to only the largest table.