Hosting Tutorial & Guide

How to Clean Up and Optimize a WordPress Database Easily

updated on Jun 10, 2015
How to Clean Up and Optimize a WordPress Database Easily After a WordPress site runs for some time, it is necessary to give a cleanup to your database. As the database stores all data for your site – posts, pages, comments and more, it keeps getting larger in size, which results in slower speed for the site to load.

Therefore, our suggestion is to perform database cleanup and maintenance regularly. You can do this by using a plugin, PHPMyAdmin or MySQL command, but if you are not experienced enough in database management, do not take the risk of trying the latter two options and crashing your site.

What Do You Need to Clean Up?

A thorough WordPress database cleanup is to remove all unused and unwanted data that takes up space. But before the cleanup, you should uninstall the unused themes and plugins first to release both disk space and database storage.

Back to the topic, the things that need to be deleted mainly include:
  • Post revisions. Post revisions are good in backing your posts/pages up, but if you publish a large number of posts/pages and keep updating them, the revisions can be a big problem for database size.
  • Old auto-saved drafts. This kind of drafts are usually ignored, but they are useless and indeed build up database size.
  • Spam comments. If you do not restrict the comments on your site, you can easily get numerous comment spam which not only makes your site less secure but also adds burden to the database.
  • Unneeded plugin and theme tables. When you delete plugins or themes, some information like a specific database table created by them is left over.
Unneeded Plugin and Theme Tables

Some other aspects you may take into consideration are corrupted HTML, and orphaned post meta and comment meta, for experienced users only.

How to Clean up and Optimize a WordPress Database?

There are many plugins designed for helping users optimize WordPress databases. For this tutorial, we have tried a couple of them and found that WP-Optimize is the best choice for newbies. This plugin gains 4.9 out of 5 stars on WordPress.org for being powerful but easy-to-use.

WP-Optimize Plugin

WP-Optimize has awesome features. It offers a wide range of options for removing data, and supports automatic optimization. The email notifications and database table statistics are also highlights.

The biggest drawback of the plugin is that it does not include a backup feature. Therefore, before using the plugin, you must back up your WordPress database manually or with a backup plugin. Do not forget this task in any circumstance!

Cleaning up databases and optimizing the database tables are very easy with WP-Optimize. Upon activation, you only need to go to the plugin dashboard, check some options and click on the "Process" button. Then the plugins do all the tasks. Just wait a few seconds or minutes to see how much space is saved.

Cleanup and Optimization Options

If you want to schedule a regular cleanup, click on the "Settings" tab. In the "Auto Clean-up Settings", enable scheduled optimization, and select the frequency. Once a week or once every two weeks are recommended. You can also decide what data to be removed in the automatic cleanup.

Schedule Automatic Cleanup

When using WP-Optimize, you should note that this plugin does not optimize InnoDB tables. In addition, it does not delete any table, either. If you do want more options for removing tables, try some other database plugins like WPDBSpringClean which identifies the unused tables and allows you to delete them.

Kind Tips about Database Cleanup and Optimization

Below are some useful tips offered for WordPress users with a plan to do a cleanup.
  • Never try to delete anything in the database before making a backup.
  • For websites with steady or increasing traffic, test the plugin you would like to use locally before using it on the live site.
  • To clean up the databases of huge WordPress sites, do not use a plugin. Instead, using PHPMyAdmin or hire an experienced administrator.
  • You can install and activate the cleanup plugin only when you really need it to run.
Now you can have a try and see how cleanup and optimization make a difference to your database size.