mysql lista todas as tabelas com tamanhos

Se você quiser que todas as suas mesas sejam ordenadas por tamanho de mesa. use este snippet:


SET
@DBNAME = "test_development"; #database name

SELECT CONCAT
(table_name) AS "Tables",
CONCAT
(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT
(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT
(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT
(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND
(index_length / data_length, 2) idxfrac
FROM information_schema
.TABLES
WHERE table_schema
= @DBNAME
ORDER BY data_length
+ index_length DESC;

Resultados da amostra

+-------------------+-------+-------+-------+------------+---------+
| Tables | rows | DATA | idx | total_size | idxfrac |
+-------------------+-------+-------+-------+------------+---------+
| users | 0.00M | 0.00G | 0.00G | 0.00G | 2.00 |
| addresses | 0.00M | 0.00G | 0.00G | 0.00G | 0.00 |
| services | 0.00M | 0.00G | 0.00G | 0.00G | 0.00 |
| schema_migrations | 0.00M | 0.00G | 0.00G | 0.00G | 0.00 |
| bookings | 0.00M | 0.00G | 0.00G | 0.00G | 0.00 |
+-------------------+-------+-------+-------+------------+---------+
5 rows in set (0.17 sec)