For coders TYPO3 Tech Corner

SQL: Show all tables sorted by size in descending order

SQL: Show all tables sorted by size in descending order

This can be done easily via SQL command:

SELECT table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) AS `Size (MB)` FROM information_schema.TABLES WHERE table_schema = DATABASE() ORDER BY (data_length + index_length) DESC;

Example output:

+---------------------------------------------------------+-----------+ | Table | Size (MB) | +---------------------------------------------------------+-----------+ | cache_hash | 1742.58 | | sys_history | 680.08 | | cache_pages | 172.09 | | sys_log | 150.23 | | sys_file_processedfile | 81.80 | | tt_content | 59.35 | | sys_refindex | 55.28 | | tx_extensionmanager_domain_model_extension | 44.14 | | sys_file_reference | 43.16 | | sys_file | 34.64 | ...

By the way, we have described how to exclude unnecessary tables from a dump in another snippet.

Back

"Code faster, look at the time" - does this sound familiar to you?

How about time and respect for code quality? Working in a team? Automated tests?

Join us