Optimizing your WordPress database can help keep your site running at full-speed.
The WordPress database is the home for your website’s content, theme settings, plugin settings, users, and more. That means overtime WordPress needs to find any bit of data your site uses it has to look in the database. A bloated database can slow things down.
Optimizing your database can help remove some of that excess data. As one stackoverflow user put it:
It’s kind of like changing the oil in your car or getting a tune-up. You may think you really don’t have to, but by doing so your car runs much better, you get better gas mileage, etc. A car that gets lots of mileage requires tune-ups more often. A database that gets heavy use requires the same.
General WordPress Usage
Any WordPress site that gets updated frequently is making UPDATE and DELETE calls to the MySQL database. Overtime it just needs to be cleaned up. Similar to defragging a hard drive.
The sneakiest cause of WordPress bloat, in my humble opinion, are post revisions. A great feature for sure, but if you create hundreds of posts each with 100s of revisions your database will blow up fast.
If you happen to use the Calypso editor watch out, your post revisions will skyrocket. It’s typical for me to have 100+ post revisions by the time I’m done writing a medium size post with Calypso.
Plugin Settings and Tables
Other plugins will add their own tables to the database. This is great for keeping things nicely organized while using the plugin, but if you delete the plugin you really have no need for those tables anymore2.
Picking good plugins can help prevent some of this form of database bloat.
Optimizing Your WordPress Database
Luckily this is WordPress. It runs 28% of the internet so many others smarter than myself have developed tools to help you clean up your database.
STOP: We’re talking about your database here so before doing any of this make sure you have a backup of your site.
WP-Optimize is a free plugin that let’s you easily optimize tables, clean up post revisions, trashed posts, spam comments, and more.
All you need to do to run it is install and activate the plugin. Select the optimizations you want to run. And click the big Run Optimizations button3.
Manage WP is a service used to make it easier to manage multiple WordPress instances. It can do everything from auto-backups, plugin updates, SEO analysis, and uptime monitoring to of course, database optimization.
It’s very easy to use, once you sign up for the service and get your site added you can navigate to your site’s dashboard and see the optimizations available. The nice thing is you can take your backup from Manage WP as well.
Manual Optimization through phpMyAdmin
If you have access to phpMyAdmin you can use the built in Optimize Table option. Simply select all your tables you would like to optimize and from the dropdown select Optimize table4.
By performing this occasional bit of maintenance an optimizing your WordPress database you’ll keep your site in tip top shape. Let it slide and you may run into bigger problems down the road.