Cleaning WordPress Database

By October 8, 2015 wordpress, WordPress Tutorials
Cleaning WordPress Database

During the Course of time, the WordPress Database becomes huge. Addition of number of unnecessary tables increases the databse size. The performanc of the database degrades thus degrating the overall site performance. The site ultimately becomes sluggish. It will be bloated with unnecessary data.

Why Cleaning WordPress database is necessary?

With the passage of time, the post revisions, spam comments, inactive plugins and all other data goes into database. The Database size increases tremendously. The unnecessary data like revisions and spams and plugin data are stored in the database. To remove all this data and keep the only necessary data, we do Cleaning of WordPress Database. Thus to keep the site performance intact we do WordPress database optimization.

Cleaning WordPress Database

Now since we know why to clean the database, lets gets out hands dirty. Ohh wait ! There is one last thing to do. This may not look necessary to you. But believe me. This step is much necessary. You need to backup your files and database. Sometimes you will end of messing up with the site for no reason. If you have the backup ready then you can restore the site. If not nobody will be able to help you easy. Thus I strongly recommend to backup your site and have a copy of the site locally in your system. If you need help you can have a look at out post that describes how to backup your WordPress Site.

Once you have a backup of your site, you can start Cleaning WordPress Database with a free mind. No restriction. No fear of crash. Now to clean your WordPress database you will have few things reaady. The wordpress database name, password and other details. These details can be found in the wp-config.php file in root directory of your site. lets start with simple things and move on to the comples cleaning.

Delete Unused Plugin from your WordPress Site

WordPress database stores various data related to plugin. Even though the plugin are stored as a file system, many information are stored in the database also. The plugin data consists of huge share in the database. Thus deleting all the unused plugin helps you get started with the first step in Cleaning WordPress Database. Ther process is simple. Go to wp-admin(dashboard)>>Plugins >> delete all unused plugins. This deletes the information from database and deletes the files from the directory al well. Now since we have cleaned our database for uncessary plugin data, lets move to next part.

The next part will contains running some SQL Queries. You will need to open phpmyadmin. This is located in your hosting server panel. You may need username and password. This can be found in wp-config.php like I mentioned above. Most server does not asks for it. You just need to go to phpmyadmin and select the proper database. Your database name in wp-config.php should match with the databse that you select.

Once you are into php myadmin you will have various tab. There is a SQL query tab where you can create or paste your sql query to run.

SQL Query box

As seen in the above image you can put your SQL query in the box and press go to execute it.

Deleting Orphan data of posts and plugins

Orphan data are those information which are the but not used. It does not have links or parents. It may be those data that are left by plugin or posts. Since we have deleted many plugins so it is possible that some of the data from the plugin are there in database. It is a good idea to clean it up.

This data is present in wp_postmeta table. You can use the below query to delete these data.

DELETE FROM wp_postmeta WHERE meta_key = ‘meta-key-to-delete’;

Use the above query with your own meta-key value and the query will delete all its data related to  that meta key.





Join the discussion 2 Comments

  • SuperWp says:

    This is just an awesome article as to why we need to clean WordPress database.
    Is there any chances that deleting the orphan data from the site creates some problem sometimes.

    • wpcares says:

      Usually that should not happen if all the WordPress paradigm are followed.
      But there are too many third party plugins that use database to store data. But they do not take much care during uninstall. So there is always a possibility that on deleting the orphan data the site can behave abnormally.

Leave a Reply

Enter the Captcha * Time limit is exhausted. Please reload CAPTCHA.