MySQL: Find Out Which Table is Consuming Resources

To find out which table is consuming the most resources in MySQL, you can use the following SQL query:

SELECT table_name, engine, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "your_database_name"
ORDER BY (data_length + index_length) DESC;

Replace your_database_name with the name of your database.

This will list all the tables in the specified database, sorted by their combined data and index size. You can see which table is consuming the most resources based on the “Size in MB” column.

Leave a Comment