WordPress Database Optimization – 5 Steps To Reduce WordPress Database Size

WordPress websites have huge database size. This is because WordPress stores hell lot of information in your database. This is not all bad, the information is useful after all. But there are many other things that you can remove from the database without affecting the website. These things include your deleted posts/pages and spam comments and some other left-overs.

What Is Stored In WordPress Database

Below is the list of things that are not required by WordPress, but still take huge space in the database.

1. SPAM Comments

If you have a popular WordPress website and you use WordPress comments on it, then you will surely receive hundreds of spam comments daily. But the main problem is that WordPress stores these comments in your website’s database even after you mark them as SPAM. This increases the WordPress database hugely. As a quick solution, you can go to “Comments > SPAM” and click the “Empty Spam” button.

2. Post Revisions

WordPress creates a new database entry whenever you update your published post or re-save a draft. It also creates a new autosave after every 120 seconds when you are editing the post, but there is only a maximum of one autosave for any post that WordPress keeps. You can easily delete post revisions and autosaves or you can turn off the autosave functionality altogether.

3. Trashed Posts, Pages and Comments

Similar to the SPAM comments, trashed comments and posts also live in the database. You can delete trashed posts by going to “Posts > All Posts > Trash” and then clicking the “Empty Trash” button. Similarly, you can do this with pages and comments.

4. Settings And Data For Deactivated Plugins And Themes

Almost all the plugins and themes have a configuration menu to define their settings. Some of them even let users input data for every posts/page to show the data on the website, a simple example is the WordPress SEO by Yoast. But all the values that you input, and the settings you define are stored in the database. If you deactivate the plugin (and not delete it), all the values stay in the database until and unless you delete the plugin. This is to make sure that you have all your settings and values intact, when you re-activate the plugin. To delete all this extra data from the database, you should always delete the plugins and themes that you don’t wish to use in the future.

5. Logs

If you use plugins that have an option to keep logs, then chances are that they would be taking huge space in your database. This is because, every new log they create needs a new row in the table, and most of them don’t even have a mechanism to delete the old logs. Soon they have a huge log that unnecessarily takes up space in the WordPress database.

You can do very less to stop them. If they have an option to disable the log feature and you don’t want to use the logs, then disable it. If they do not have the option to disable, or you want to use the logs for whatever reason, then see if you have an option for automatic deletion of those logs, and if you have it, give it a very small value.

Using Optimize Database After Deleting Revisions Plugin

A great plugin that can do most of the above mentioned things with a single click, and even on a schedule (automatically). Important things that it can do for you:

  1. You can keep x number of post revisions. It will delete all the previous ones.
  2. Delete trashed items
  3. Delete spammed items
  4. Delete unused tags
  5. Optimize WordPress database tables

And all of this on a schedule. This plugin alone can help you optimize WordPress database leaving no effort on your part.

WordPress Database Optimization Using Plugin

Link: Optimize Database after Deleting Revisions

Related Post