Skip to content

Instantly share code, notes, and snippets.

@oliworx
Created May 6, 2021 14:20
Show Gist options
  • Save oliworx/a3fd7fb6007b13fcefd24a8294d4c1a3 to your computer and use it in GitHub Desktop.
Save oliworx/a3fd7fb6007b13fcefd24a8294d4c1a3 to your computer and use it in GitHub Desktop.
Get the size of MySQL/MariaDB tables
SELECT
TABLE_NAME AS `Table`,
ROUND((DATA_LENGTH ) / 1024 / 1024) AS `Data (MB)`,
ROUND((INDEX_LENGTH) / 1024 / 1024) AS `Index (MB)`,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Total (MB)`
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = "my_db_name"
ORDER BY
(DATA_LENGTH + INDEX_LENGTH)
DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment