• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Cleaning Up Left Over Plugin Database Tables

Unlike traditional website platforms which run purely on HTML, WordPress includes both files and database tables.

The core software uses some tables which are crucial for the software to work however your plugin tables aren’t.

When you install a plugin it generally adds tables to your database.

The problem is, it doesn’t delete them when you delete the plugin. It normally only deletes the plugin files.

See this screenshot as a typical example:

Delete Plugins

Its clear that this function within your dashboard only deletes the files created when you installed the plugin.

Note: Not all plugins create database tables and some plugins give you the option to uninstall the plugin tables as well.

The reason most plugins don’t include the uninstall function is because the plugin author hasn’t included it in the plugin. Simply as that.

It might not work if the plugin isn’t coded correctly and most plugins are free so why would they risk it?

Plugins can have uninstall support easily built in, via an uninstall.php file (easiest way). This file simply gets executed when you select to “delete” the plugin from the Plugin Manager. Ideally, the plugin author would use this space to remove options, tables, etc.

So what next?

How do we remove all the unwanted tables left over in your database after you tried out different plugins but decided you really don’t like or need them?

There’s 2 ways to do this:

  1. Dig into your tables and delete them manually
  2. Install some more plugins which do this job for you
Big Caution: Backup your database before deleting tables.

Plugins That Remove DB Tables

There’s several plugins which i have tested on a local installation that work well.

I’ll now give you an overview of how i used them to remove the tables left over after deleting unwanted plugins .

By the way, my DB is over 100mg and i have tested hundreds of plugins before i started using a local installation of WordPress so it’s perfect for this task.

Plugins Garbage Collector

After you install Garbage Collector, you’ll find the settings under the Tools tab in your Dashboard.

Plugins Garbage Collector

Select Search non-WP Tables and click Scan then wait.

You’ll then get a list of the non core tables still included in your database that belong to plugins which have have deactivated or deleted.

Non Core Tables

What you can do then is check them and Delete the Tables.

Another warning from the author: Operation rollback is not possible. Consider to make database backup first. Please double think before click button.

Sorry to sound like a broken record folks!

It’s not awalys crystal clear which plugins use which tables as some of the table names are weird but you can be assured they are non core.

If your server space is managed by WPEngine, then you get the awesome backup and restore tool that reverses any errors quickly and easily.

Before you nearly die of boredom, let’s check out a couple more plugins which delete options and optimize your db.

Clean Options

This plugin cleans up any options in your wp_options table which have become orphaned after you deleted the plugin which created them.

Note: This doesn’t clean up any options which are used by plugins or themes that have been deactivated. You’ll need to delete the files first in order to use this plugin for cleaning up their options.

Clean Options

Click Find Options.

You’ll then get a screen full of these.

Possibly Orphaned Options

Its clear most of these have been created by plugins so you can easily delete the one’s which are individually.

Any that you’re not clear on, follow the instructions to search for more info on them so you can check what they’re used for.

Option Search Box

Option Name Search

Pretty clear this is a tedious task however you will learn a lot of how a database works if that’s your thing!

Database Optimization Plugins

There’s a couple of plugins that i use weekly which simply remove some junk.

They are:

  1. WP Optimize and
  2. WP Clean Up

WP Cleanup

I’ve already written about how to optimize your database.

They’re very basic and easy to use and should be used before you start cleaning up your tables.

Basically they Optimize your database tables and remove:

  • Post revisions
  • Spam Comments

Result After Cleanup

Depending on how many unused tables you cleaned up, you will find that your site will run significantly faster and more efficiently.

Pingdom Tools

I know my database is now about half the size as i created a backup before and after the cleanup.

This is before i’ve even removed any options.

Databases

Feels great when you’ve optimized your db and your site loads faster!

I’ll also be writing about how to do this job manually at some stage if you’re interested.

Reader Interactions

Comments

  1. James says

    July 30, 2012 at 3:28 pm

    Brad,
    Thanks for this. Have you got a similar one for cleaning up the Media gallery – I have so many unused images, but I don’t want to trash my site in getting rid of them and find I have to put them back !

    BWs
    James

    Log in to Reply
    • Brad Dalton says

      July 30, 2012 at 3:54 pm

      Hi James

      Good question. I don’t think i’ve written about that before so i’ll find a solution for cleaning up unused images and write about it soon.

      Log in to Reply
      • Brad Dalton says

        July 30, 2012 at 5:15 pm

        Here’s the link to a simple tutorial on how to find and cleanup unused image files http://wpsites.net/media/finding-deleting-unused-images-in-your-media-library/

        Log in to Reply
  2. Michael Cordova says

    July 28, 2012 at 11:58 pm

    Brad,
    This is on my list for multiple sites we have in development right now. Totally appreciate your thoughtful efforts here. I’ll dig into it

    Log in to Reply
    • Brad Dalton says

      July 29, 2012 at 12:02 am

      No worries Michael. Put this one off for a long time but its really not difficult.

      The only time consuming part would be to check all the options manually to be on the safe side before removing them.

      What you could do is take a backup of your db after using garbage collector and use that as the restore point if you accidently remove an important option and break you site.

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.