-
-
Save benklocek/fdca1a51d498abd5afb5f377530c607b to your computer and use it in GitHub Desktop.
Useful SQL Queries
This file contains 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
#Get the size of each table, ordered by largest to smallest | |
SELECT table_name AS "Tables", | |
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" | |
FROM information_schema.TABLES | |
WHERE table_schema = "YOU+TABLE+NAME+HERE" | |
ORDER BY (data_length + index_length) DESC; | |
#Get the size of the entire DB | |
SELECT table_schema "DB Name", | |
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" | |
FROM information_schema.tables | |
GROUP BY table_schema | |
#Get the size of each option sorted by size for wp_options ( props @jtsternberg ) | |
SELECT | |
opts.option_id 'Option ID', | |
opts.option_name 'Option Name', | |
LENGTH(opts.option_value) "Size in bytes", | |
round(((length(opts.option_value)) / 1024), 2) "Size in KB", | |
round(((length(opts.option_value)) / 1024 / 1024), 2) "Size in MB" | |
FROM | |
wp_options opts | |
ORDER BY CHAR_LENGTH(option_value) DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment