Skip to content

Instantly share code, notes, and snippets.

@phagedorn
Last active August 29, 2015 14:06
Show Gist options
  • Save phagedorn/65d9367dca63a5232e40 to your computer and use it in GitHub Desktop.
Save phagedorn/65d9367dca63a5232e40 to your computer and use it in GitHub Desktop.
top_5_largest_tables.sql
# Query to list top 5 largest tables in the database
# http://www.thegeekstuff.com/2008/11/overview-of-mysql-information_schema-database-with-practical-examples/
# This examples gives the top 5 largest space occupying tables in the database along with it’s size in MB.
SELECT concat(table_schema,'.',table_name) table_name,
concat(round(data_length/(1024*1024),2),'M') data_length
FROM information_schema.TABLES
ORDER BY data_length DESC LIMIT 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment