Skip to main content

Find out MySql table sizes using drush

Member for

2 years 7 months
Submitted by admin on

To find out the sizes of the tables in your databases, start by accessing the database using Drush with the following command.

$~ drush sqlc

Select the database needed for testing

mysql> SHOW DATABASES;
mysql> USE <DATABASE NAME>;

This query will use the currently selected database and show all the tables in megabytes.

SELECT table_name ,
  round(((data_length + index_length) / 1024 / 1024), 2) as SIZE_MB
FROM information_schema.TABLES
WHERE table_schema = DATABASE() ORDER BY SIZE_MB DESC;