Do you automatically optimize MySQL tables?

As time passes, a MySQL database table can get “fragmented” by adding and deleting records. This slows down the database.

To avoid this problem, we automatically run MySQL’s OPTIMIZE TABLE command once a month on database tables that are smaller than 100 MB.

Optimizing a table blocks (delays) INSERTs and UPDATEs for a few seconds, so we do it late on a Saturday night to avoid potentially slowing down your scripts at a busy time of the day.

We don’t automatically optimize tables larger than 100 MB, because doing so might delay scripts for more than a few seconds. If you have tables larger than 100 MB that often change, you may want to occasionally optimize the table yourself to avoid slowdowns.