Magento 2 troubleshooting › Database
Which Magento database tables are the biggest, and which can be cleaned?
Short answer: One query on information_schema lists table sizes. The usual giants are carts (quote), cron history, visitor and report logs, and on Adobe Commerce the admin action log. Most can be trimmed through Magento settings rather than by hand.
Check it step by step
These queries only read data. Run them on a copy of your database if you can, or ask your developer to. If your tables have a prefix (set in app/etc/env.php), add it to each table name.
The 25 largest tables
Works on Magento Open Source and Adobe Commerce:
SELECT table_name, table_rows,
ROUND((data_length + index_length) / 1024 / 1024) AS size_mb
FROM information_schema.tables
WHERE table_schema = DATABASE()
ORDER BY data_length + index_length DESC
LIMIT 25;
table_rows is an estimate for InnoDB tables.
How to fix it
- quote, quote_item: lower Quote Lifetime (Sales › Checkout › Shopping Cart); cron removes old carts.
- cron_schedule: lower the history lifetimes in Advanced › System › Cron.
- customer_visitor, customer_log, report_event, report_viewed_product_index: set the log cleaning in Advanced › System › Customer Logs, or turn off reports you don't use in General › Reports.
- magento_logging_event (Adobe Commerce): archive or shorten the admin action log in Advanced › System › Admin Actions Log Archiving.
- Never truncate
sales_*,customer_*orcatalog_*tables; and take a backup before any clean-up.