Optimize table in MySQL
OPTIMIZE TABLE command is useful to defragment the database tables. It is particularly useful when you have deleted a large portion of a table or if you have made massive changes to a table with variable-length rows.
To do so, execute the following statement
mysql> OPTIMIZE TABLE my_table;