Created
May 21, 2011 15:01
-
-
Save jystewart/984587 to your computer and use it in GitHub Desktop.
Query to generate OPTIMIZE TABLE statements for all fragmented tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT CONCAT('OPTIMIZE TABLE ', TABLE_SCHEMA,'.',TABLE_NAME, ';'), Data_free from information_schema.TABLES where TABLE_SCHEMA NOT IN ('information_schema','mysql') and Data_free > 0 AND ENGINE NOT IN ('INNODB', 'MEMORY'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment