Forked from Kevinlearynet/largest-tables-in-mysql-database.sql
Created
November 13, 2019 22:52
-
-
Save Sanabria/32f633c5b1c5027020b4e98f5150b6c5 to your computer and use it in GitHub Desktop.
Find the largest (sized by MB) tables in your MySQL database. Especially useful for diagnosing and fixing a bloated WordPress database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find the largest tables in your MySQL database | |
SELECT | |
table_name as "Table", | |
table_rows as "Rows", | |
data_length as "Length", | |
index_length as "Index", | |
round(((data_length + index_length) / 1024 / 1024),2) as "Size (mb)" | |
FROM information_schema.TABLES | |
WHERE table_schema = "%%YOURDATABASE%%" | |
ORDER BY `Size (mb)` DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment