nenes25 / prestashop_console

Prestashop Console Tools
Open Software License 3.0
48 stars 15 forks source link

New Command Analyze:tables:size #242

Closed nenes25 closed 2 years ago

nenes25 commented 2 years ago
Questions Answers
Branch? 1.6 / 2.0
Command name? Analyze:tables:size
Command category? other
Command arguments? None
Command options? List only the x biggest tables --limit = x
Command return? List what the command will return
success : A table with the x biggest tables of the instance
error : no possibles errors
Command description? This command will check the size of all the table of the instance and will return the 10 biggest by default
Possible impacts? None
nenes25 commented 2 years ago

Sql request :

SELECT TABLE_NAME, TABLE_TYPE, TABLE_COMMENT, AUTO_INCREMENT, TABLE_ROWS, round(((data_length + index_length) / 1024 / 1024), 2) "TABLE_SIZE" FROM information_schema.TABLES WHERE table_schema = DATABASE() ORDER BY (data_length + index_length) ASC;

SELECT SUM(table_rows) "DB_ROWS", round(((SUM(data_length) + SUM(index_length)) / 1024 / 1024), 2) "DB_SIZE" FROM information_schema.TABLES WHERE table_schema = DATABASE() GROUP BY table_schema