Skip to content

Instantly share code, notes, and snippets.

@kitzberger
Last active April 15, 2021 16:30
Show Gist options
  • Save kitzberger/ce1fe56074cde702bfcd1fb84eab5e8c to your computer and use it in GitHub Desktop.
Save kitzberger/ce1fe56074cde702bfcd1fb84eab5e8c to your computer and use it in GitHub Desktop.
Optimize MySQL table sizes
-- Determine MySQL table size
SELECT
TABLE_NAME, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) 'Size in MB'
FROM information_schema.TABLES
WHERE TABLE_TYPE='BASE TABLE' AND table_schema = 'typo3'
ORDER BY data_length ASC;
-- Is MySQL configured to use separate files per table?
SELECT @@innodb_file_per_table;
-- Optimize tables
DELETE FROM tx_powermail_domain_model_mail WHERE deleted=1;
DELETE FROM tx_powermail_domain_model_answer WHERE deleted=1;
OPTIMIZE TABLE tx_powermail_domain_model_mail;
OPTIMIZE TABLE tx_powermail_domain_model_answer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment