Created
November 12, 2020 08:39
-
-
Save daubac402/fa1f5ad3762f5de5d2c09296f9a08503 to your computer and use it in GitHub Desktop.
Prepare to OPTIMIZE MySQL tables
This file contains hidden or 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
1. Check current defrag status: | |
SQL> select table_name,round(data_length/1024/1024) as data_length_mb, round(data_free/1024/1024) as data_free_mb from information_schema.tables order by data_free_mb; | |
2. Optimize one table or multi: | |
SQL> OPTIMIZE TABLE your_table_name; | |
SQL> OPTIMIZE TABLE your_table_name1, your_table_name2, your_table_name3; | |
(or) | |
Optimize all of your tables in "your_database": | |
(from bash, not in mysql client bash) | |
# mysqlcheck -o your_database -u your_user -pYOUR_PASSWORD | |
(or even) | |
Optimize all of your databases: | |
# mysqlcheck -o --all-databases -u your_user -pYOUR_PASSWORD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment