How to Cleanup Database by Removing Old Plugin Tables

One way to speedup a WordPress site is by optimizing its database. This is very much essential as over time we install many plugins on the site, and then deactivate or remove unused plugins when we don’t require it anymore. However, some plugins also create their own database tables and those tables are not deleted even after deleting the plugin. In this tutorial, you’ll learn how to easily cleanup database by removing old plugin tables.

Let’s first understand what happens when you install a new plugin and what happens when you delete it.

When you install a plugin, it will also create a new table and add it to your database. The settings and other data are stored in this table.

Now, when you delete the same plugin, it will remove the files but sometimes it won’t remove the database table that it had created. The reason for this is that plugin developer has not provided any function to remove the table.

Note that not ever every plugin creates database tables, and also a few plugins have the option to delete tables when they’re removed from the site.

So now the question is how to remove this unwanted database table that’s left even after you’ve deleted the plugin? Let’s take a look at two different methods to remove this unwanted database table.

Important Note: Before proceeding forward, I would highly recommend you take a full backup of WordPress database table, so that just in case something goes wrong, you can restore the database.

How to remove database table of deleted WordPress plugins:

Step 1:
Install and activate Plugins Garbage Collector plugin on your site.

Step 2:
Once it’s activated, go to Tools > Plugins Garbage Collection.

On this page, by default the option for “Search non-WP tables” is selected, and you’ll need to go ahead and click on Scan Database button. This will start the search for such plugins and it might take a few minutes depending on your site.

optimize wordpress database

Step 3:
Once the search is complete, you’ll get a list of non-WordPress tables belonging to plugins that you have deactivated or deleted.

plugin garbage collector

However, it’s still not very clear on which table belongs to which plugin so you’ll need to guess the name of the plugin. For example, in the above screenshot, you can see a table “wp_prli_groups”, and you can Google this to know which plugin this table belongs to.

If you’re no longer using this plugin, and don’t intend to use it in future then you can select this table, and click on the “Delete Tables” button. Even if you don’t find the name of the plugin, rest assured this is a non-WordPress table and normally it should be safe to remove it.

Please note that this will delete the table, along with its settings. This means that the next time you install the same plugin, you’ll need to manually configure it again.

For example: Let’s say you’ve previously installed and used Gocodes plugin, and this scan has found some tables related to Gocodes plugin. When you remove the table using this method, it will also delete the data / settings associated with Gocodes plugin.

You’ll be able to remove the table only when you’ve deactivated and deleted the plugin on your site.

Manual Method

If you don’t want to use any plugin for this purpose, then here’s how you can cleanup your database by removing old plugin garbage manually. Please note that this method is only for those who have used phpMyAdmin and are familiar with it.

Also I would recommend you to do a complete database table backup before proceeding forward.

Once you’ve completed a database backup, go to phpMyAdmin from cPanel.

Select your WordPress table from the left side, which will expand it.

Now click on the plugins table name, which will open its options. From here, click on Operations tab.

From this page, click on “Drop the table (DROP)”. You’ll be prompted for a confirmation, click on OK to confirm.

So that’s how you can cleanup database table, and remove the left over table of old deleted plugins.

If you like this article, then please follow us on Twitter and Facebook .

If you have any questions, then feel free to comment below.

Leave a Comment

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