SQL
Joomla! 6
Joomla! 5
Joomla! 4
Joomla! 3 (Legacy)
Database
Basic
Audit the Largest Joomla Database Tables in Megabytes
Lists the top 20 largest tables (data + index size) to spot bloated tables such as #__session, #__history, #__redirect_links or logs.
sql/audit_table_sizes.sql
SELECT
TABLE_NAME AS tabela,
ENGINE,
TABLE_ROWS AS linhas_aprox,
ROUND(DATA_LENGTH / 1024 / 1024, 2) AS dados_mb,
ROUND(INDEX_LENGTH / 1024 / 1024, 2) AS indices_mb,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024, 2) AS total_mb
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = DATABASE()
ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC
LIMIT 20;
Completely read-only and compatible with MySQL 5.7, 8.x, 9.x and MariaDB.
Technical explanation and best practices
An essential read-only diagnostic query to pinpoint storage bloat or slow backups caused by oversized session, history, redirect or log tables.