Cleanup WordPress Database with WP-Optimize Plugin

Whatsoever the structured manner you build you WordPress site, over a period of time it is mandatory to cleanup your database to remove unnecessary data and release storage space. For a bigger site this will be a periodic activity needed to stop building up junk data on your database. Manually cleaning up database is beyond the scope of a normal WordPress user and plugins are the easiest way to make it feasible. WP-Optimize is one such a handy plugin offers various features to cleanup WordPress database with one click. In this article we will discuss various features of WP-Optimize plugin and how can you effectively use the plugin settings to cleanup your database.

Why Should You Cleanup and What Should You Cleanup?

Basically cleanup activity is required to delete unnecessary auto saved versions of your post and comments.

  • WordPress saves a version of the post every time you modify the content. This is a very useful feature for restoring purpose and in multi-author environment. But for a single author site this auto saved versions over a period of time will add up database size without any real value addition. WP-Optimize plugin allows you to delete these post versions in one click.
  • Delete draft posts and posts in trash you have accumulated over a period of time.
  • Delete spam and unapproved comments in one click to save time and space.

Installing WP-Optimize Plugin

WP-Optimize is a free plugin which you can install right from the WordPress admin interface by navigating to “Plugins > Add New”. Search for WP-Optimize and install the latest version of the plugin.

Install WP-Optimize Plugin
Install WP-Optimize Plugin

There will be a new menu “WP-Optimize” added in the admin menu section once you activated the plugin.

Precautions Before Database Cleanup

As with every database related activity, ensure the below are taken care before doing cleanup activity with WP-Optimize:

  • Backup your complete WordPress site including files and database.
  • Most hosting companies allows you to run SQL queries on the database from WordPress admin interface (using plugins). If you have a doubt confirm this with your host and ensure you can run SQL queries on database.
  • Ensure all comments are approved and there are no pending unapproved comments.
  • Go through the plugin settings and understand each option. The options marked in the red are dangerous and not required for normal database cleanup.

WP-Optimize Plugin Features

Plugin settings are divided into four sections as below:

  1. Optimizer
  2. Tables
  3. Settings
  4. Info

We discuss various options available under each section.

Plugin Requirements

  • WordPress Version: 3.8 or later
  • PHP Version: 5.1.xx
  • MySQL Version: 5.1.xx


Info tab shows plugin development updates in GitHub, translation information, plugin resources and donation button.


Settings tab provides options for “General Settings” and “Auto Clean-up Settings” which you need to setup before running the cleanup action.

WP-Optimize Plugin Settings
WP-Optimize Plugin Settings
  1. It is good idea to keep few weeks of data instead of cleaning up till date. Choose the number of weeks from the drop-down to keep the data for till the selected weeks.
  2. Enabling admin bar shortcut will add a shortcut in the WordPress admin top bar.
  3. Enable or disable trackbacks throughout the site.
  4. Enable or disable comments throughout the site.
  5. Select the frequency from the dropdown and schedule the cleanup process as per the “General Settings” and “Auto Clean-up Settings” options. You can also enable email notification for the results to be sent to your inbox after each cleanup.


Here you can see the list of tables with size and type along with the data on how much optimization is possible. Since InnoDB tables can’t be optimized normally the saving in database size here is very nominal.


Select the data you want to delete like spam comments, post revisions, draft posts, etc. Once the required settings are selected go through “Settings” tab to choose how many weeks of data you want to retain before click on the “Process” button.

WP-Optimize Plugin Optimizer Options
WP-Optimize Plugin Optimizer Options

Database Cleanup Results

Once you click on the process button it may take a while before the results depending on the database size and content to be deleted. Below is how the plugin shows the cleanup results:

WP-Optimize Database Cleanup Results
WP-Optimize Database Cleanup Results

General Features of WP-Optimize Plugin

Below are the tasks you can do with this plugin:

  • Enable or disable comments and trackbacks throughout site for all post.
  • Delete all post versions, draft posts and posts in trash.
  • Delete comments in spam, unapproved and trash folders.
  • Remove Akismet and other metadata from comments.
  • Removal of all trackbacks / pingbacks and transient options.
  • Keep chosen number of week’s data and delete remaining all.
  • Possible to enable or disable scheduled cleanup with email to notification of results.
  • View statistics of tables and find how much space is saved. Also view the results statistics once cleanup is done.
  • Plugin settings are enabled only for site administrators.

Editorial Staff at WebNots are team members who love to build websites and share the learning with webmasters community. Follow us on Facebook and Twitter.

Leave a Comment