Update: I located a WordPress plug-in that can be scheduled to automate your database optimization: http://wordpress.org/extend/plugins/wp-database-optimizer/

Many WordPress customers ask about their database disk use, or their disk quota in general, because they are getting warning emails, or having performance issues with their site. Many times, the cause of a large database has to do with overhead in the database that hasn’t been cleaned out in a while. Overhead is caused by deleting lots of records often, and the tables become fragmented. Optimization cleans up this fragmentation. Here’s how to do it easily in WordPress 2.9.X and greater:

1. Edit your WordPress “wp-config.php” file and add the following line, perhaps near the top so it’s easy to find for undoing afterwards:

define(‘WP_ALLOW_REPAIR’, true);

2. Visit the special “/wp-admin/maint/repair.php” URL and click the “Repair and Optimize Database” button. It’s usually at one of these locations:

http://yourdomain.com/wp-admin/maint/repair.php
or
http://yourdomain.com/blog/wp-admin/maint/repair.php/wp-admin/maint/repair.php

It will scan, repair, and optimize all your WordPress tables.

3. Edit your wp-config.php file again, removing the line you added. Or, set it to false.

That’s all there is to it. Reach out on Twitter if you have any questions or concerns.