How to get the size of all MySQL Tables in all Databases (and other size-related queries)

MySQL Master-Master Replication setup in 5 easy steps

Yesterday I was trying to investigate through an odd size increment affecting one of our MySQL databases. Since I didn't knew about the table(s) affected by the issue, the first thing I needed to do was to take a look at each table size among the various DB that were there.

I managed to perform such analysis in few minutes with these great queries, loosely based upon those present within this StackOverflow answer.

Size of a single table in a single database

Size of all tables in a single database (largest first)

Size of all tables in every database (largest first)

Size of all Databases (largest first)

If you use the MySQL Workbench, you can achieve the same results from the GUI by doing the following:

  • Right-click the schema name and click "Schema inspector".
  • In the resulting window you have a number of tabs. The first tab "Info" shows a rough estimate of the database size in MB.
  • The second tab, "Tables", shows Data length and other details for each table.

That's it for now... happy querying!

 

 

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.