I was poking around the WordPress core code the other day and I discovered a file hidden away in it’s own directory in the wp-admin folder. Further investigation revealed a built in method for optimizing database tables that is a lot easier and safer than the optimizing method I suggested a few weeks back.
Here’s how to use it:
1) Backup your database
I would still recommend that you back up your database before you try to repair it. Follow my instructions for backing up your database from my first post, then come back here to finish the job.
2) Allow Repair Access
Find the wp-config.php file (usually located in the root of your site), open it up and add the following line anywhere – I usually add it at the bottom so I can find it easily when I’m done:
define('WP_ALLOW_REPAIR', true);
3) Optimize your Database Tables
Open up a browser and head over to http://your-site.com/wp-admin/maint/repair.php. You should be presented with the following screen:
If your screen looks like this…
…you haven’t added the code from step 2 to your wp-config.php file correctly – check it isn’t placed next to some comment markers (// or /* ).
Click on the Repair and Optimize Database button. WordPress will shut down your site while it optimizes your database tables for you – it may take a few moments to complete depending on the size of your database.
When it’s finished, you should see a report screen like this telling you which tables have been optimized:
4) Remove Repair Access
Open up your wp-config.php file again, and remove the line you added earlier:
define('WP_ALLOW_REPAIR', true);
This is to stop other people coming along and messing around with the Repair settings without you knowing.
If you had a huge database with hundreds of posts and pages, then doing this may net you a slight increase in the speed of your site. Bonus!





