In a previous post I covered converting all of your MySQL MyISAM tables to InnoDB. Lets take that a step further and optimize all of the tables in the DB.
First, create a query to generate all of the needed SQL statements to optimize each table in the DB.
The output generates an optimization query for each table.
Copy and paste these results and run the queries. After some time all of the tables in the DB will be optimized.