Quickly retrieve size of all tables in a MySQL database
A friend ran into an issue with their Wordpress database becoming huge. First step was to figure out which table(s) was causing the issue. Doing an online search came up with this handy little MySQL query which returns the size in MB for all the tables in a database:
SELECT table_name AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
WHERE table_schema = "database_name"
ORDER BY (data_length + index_length) DESC;
Be sure to replace "database_name" with the name of your database. This query is thanks to this post from the website Upon my shoulder.
Incidentally, the issue in Wordpress ended up being related to Akismet with a clean-up solution here.