Site icon Ryadel

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!

 

 

Exit mobile version