You are here
MySQL: Reporting Size Of All Tables
This is a query to report the number of rows and the estimated size of all the tables in a MySQL database:
SELECT
table_name,
table_rows,
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS mb_size
FROM information_schema.tables
WHERE table_schema = 'maindb;
Results look like:
table_name table_rows mb_size
------------------------------------------- ---------- -------
mageplaza_seodashboard_noroute_report_issue 314314 37.56
catalog_product_entity_int 283244 28.92
catalog_product_entity_varchar 259073 29.84
amconnector_product_log_details 178848 6.02
catalog_product_entity_decimal 135936 16.02
shipperhq_quote_package_items 115552 11.03
amconnector_product_log 114400 767.00
amconnector_productinventory_log_details 114264 3.52
This is a very useful query as the majority of MySQL applications are poorly designed; they tend not to clean up after themseves.
- Log in to post comments