WordPress Maintenance 101: How to Optimize and Repair Database Tables

July 7, 2010  | 
4 Comments

From time to time it is a good idea to do a little housekeeping with your WordPress installation, especially if you’ve been experimenting with and deleting plugins. MySQL databases don’t clean themselves. Optimizing your database is something akin to when you defrag your hard drive or change the oil in your car. It will help to free up disk space and keep your database running smoothly.

How to Optimize Your WordPress Database

Optimizing database tables can be done manually using phpMyAdmin or by using a plugin. I’m of the opinion that if you don’t absolutely require a plugin to do it, then it’s best not to add another. However, if you’re not familiar with phpMyAdmin, then a plugin may be a safer option for you.

Plugin Options:

WP-Optimize: This is a database cleanup and optimization tool. It allows you to remove post revisions, comments in the spam queue, un-approved comments within few clicks.

WP Database Optimizer: This plugin allows you to optimize your WordPress tables on a schedule. It uses the WordPress Database Class to do the work, and you can set the number of days in between optimizations.

Clean Options: This plugin finds orphaned options and allows for their removal from the wp_options table.

Optimization using phpMyAdmin:

If you’re slightly more adventurous and you want to get a hands-on idea of what’s going on with your database, open up phpMyAdmin.

Step 1: Check for Overhead

Step 2: Choose “Check All Tables Having Overhead”

As shown in the image above, you’ll be able to check all the tables that need to be optimized. Once they are checked, select “optimize table” from the drop down menu. This will take care of all of your tables at once. You should see this kind of success message:

How to Repair WordPress Tables

Occasionally you may have a table crash. When this happens, one symptom might be that all of your posts seem to have disappeared, or perhaps all of your drafts. You may even get a message in phpMyAdmin telling you that one of your tables haves crashed. No need to worry. Repairing tables is very easy.

Step 1: Login to phpMyAdmin and select the affected database

Choose the database that pertains to your WordPress blog. If you have only one it should be automatically selected.

Step 2: Check the boxes by the tables that need repair.

Once the boxes are selected, go to the drop down menu and choose “Repair Table”. You should see a success message when it’s completed.

How to Automatically Repair Your WordPress Database

Occasionally, your database may become so corrupt that you cannot login. This is a time when you might want to enable WordPress’ own ability to optimize the database. WordPress 2.9 and later has automatic database optimization support, which you can enable by adding the following define to your wp-config.php file only when the feature is required:

define('WP_ALLOW_REPAIR', TRUE);

You can find the script it uses at: at {$your_site}/wp-admin/maint/repair.php

Above all else, make sure to backup your database before making major optimization efforts or attempting to repair tables. You may thank yourself later. There are many more ways that you can optimize your WordPress database, but these are a couple of the basics to get you started. Set up a regular schedule for optimization and keep your sites running smoothly!

Featured Plugin - Easily integrate your WordPress site with Facebook

Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Well, The Ultimate Facebook plugin has got that all covered!
Find out more

Featured Plugin - Turn any WordPress page into a fully featured wiki!

To get a wiki up and running you used to need to install Mediawiki and toil away for days configuring it... not any more! This plugin gives you *all* the functionality you want from a wiki, in WordPress!!!
Find out more

Featured Plugin - Host sites, get paid, just like WordPress.com

If you've ever wondered how you could offer a paid site management and hosting service, then this is the plugin for you. Offer a freemium or paid service, for any niche you like, it's powered Edublogs.org to success already!
Find out more

Featured Plugin - Start your own Quora / StackOverflow / Yahoo Q&A site

It's now incredibly easy to start your own Q&A site using nothing more than WordPress - The Q&A plugin simply and brilliantly transforms any site, or page, into a perfect support or Q&A environment.
Find out more

Featured Plugin - Every great SEO tweak you need, in one snazzy bundle

Fully integrated with the SEOMoz API, complete with automatic links, sitemaps and SEO optimization of your WordPress setup - this is the only plugin you need to help you rank your site number 1 on Google - nothing else compares.
Find out more

Featured Plugin - Send beautiful html email newsletters, from WordPress!

Now there's no need to pay for a third party service to sign up, manage and send beautiful email newsletters to your subscriber base - this plugin has got the lot.
Find out more

Featured Plugin - Add bottom corner (or anywhere else) chat to your site

No javascript required, no third part chat engine, just fully featured chat right in your own database on your own WP sites - couldn't be easier.
Find out more

Featured Plugin - Start Your Own Powerful Membership Site

If you're thinking about starting a paid, or just private, membership site then this is truly the plugin you've been looking for. Easy to use, massively configurable and ready to go out of the box!
Find out more

Featured Plugin - Open an Online Store with MarketPress

Out of all the WordPress ecommerce plugins available, this has got to be the winner - easy to configure, powerful functionality, multiple gateways and more. A simply brilliant plugin!
Find out more

4 Responses to WordPress Maintenance 101: How to Optimize and Repair Database Tables

  1. Alternativ to phpMyAdmin you can use the small plugin Adminer in WordPress directly, very fast and include the backend of your blog.

  2. sorry, forgotten the link for switch to the plugin: http://wordpress.org/extend/plugins/adminer/
    maybe you can edit my comment

  3. Pingback: Auto Repair Shops Slammed With Hail-Damaged Cars | car auto insurance

  4. Pingback: How to Unlock the Secret “All Settings” Menu in the WordPress Dashboard - WordPress, Multisite and BuddyPress plugins, themes, news and help – WPMU.org

Click on a tab to select how you'd like to leave your comment

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting