A Magento database can grow large over time. Before you investigate or delete individual tables, identify which tables consume the most space.

The following SQL query lists the 20 largest tables, including data size, index size and total size:

YOUR_MAGENTO_DATABASE Replace this with the actual name of your Magento database. You can find it, for example, in app/etc/env.php under dbname.

The Total_MB and Total_GB are particularly useful because it includes data and indexes. This helps spot unusually large cron, quote, log or extension tables.

The column Rows_Estimated should be treated only as an approximate value for InnoDB. For locating especially large tables, DATA_LENGTH and INDEX_LENGTH are more important.

The query does not change any data and is a useful first check before investigating why your Magento database has grown so large.

Finding the Largest Database Tables Using SQL
Need help implementing this solution, or still looking for a fix to your Magento problem? Get in touch and I will be happy to help with your project.
Tags: