Direkt zum Inhalt

Devbits

Kleine Code-Schnipsel aus unserem Alltag mit Drupal, PHP und DevOps: Problem, Lösung, Code.

13.11.2025 | Marc Hitscherich

List MySQL tables by size

You need to sort MySQL tables by size.

SELECT table_name AS `table`, round(((data_length + index_length) / 1024 / 1024), 2) `size in MB`
FROM information_schema.TABLES
WHERE table_schema = "DATABASE_NAME"
ORDER BY `size in MB` DESC
LIMIT 10;

Issue:

You need to sort MySQL tables by size.

Solution:

The snippet shows the size of the 10 biggest tables. DATABASE_NAME needs to be replaced by your database name.