How To Easily Clean Up Your WordPress Database

How To Easily Clean Up Your WordPress Database

Why it’s so important to clean up your WordPress database. All WordPress websites are comprised of two parts – the files which contain media, themes, and plugins and the database which contains the settings, posts, post meta, users and their credentials, and so forth.

The file size of the WordPress database can vary, depending on the site. It can range from as little as 1MB to a few or tens of gigabytes. 

It is important to optimize your database for a number of reasons. A bloated database can slow down the site and the backend, or even crash it. Sometimes a loss of data can occur. 

If the database is large, it doesn’t necessarily mean that it is not optimized and vice versa. If you are selling WooCommerce products, your database will surely grow in time. However, redundant data will pile up after a while, so, it is important to clean your WordPress database periodically.

Content:

What Are The Reasons My Database Is Bloated?

Clean Up WordPress Database Techniques

What Are The Reasons My Database Is Bloated?

Unused WordPress Plugins

Whenever you install WordPress plugin (e.g. WordPress SEO plugin like Yoast), new tables are added to the database. Even after deleting unused plugins, often the tables stay behind. This is not a bad thing, especially if you wanted to try a different plugin and come back to the old one later. In most cases, however, this is just redundant data that needs to be removed.

There are some plugins that use the default WordPress tables. This makes removing the unnecessary data all the more difficult since you can’t simply delete the tables. Luckily, there are ways to optimize these tables as well.

Unnecessary Comments

Each day you go through a big portion of comments and are pretty happy with what you see. Your users/fans love you. Then, something pokes you in the eye. It’s either a spam comment or just something you don’t approve of. These comments then end up in dusty “folders” of your database. Why would you let them increase databases size? Clean up your database and be done with it.

Deleting spam (spammed comments), comment meta or trashed comments is rather easy. To learn the quick way, just continue reading.

Revisions – Clean Up WordPress Database

Did you know that every time you make any changes in your posts, WordPress saves both the old and the current version? It’s actually pretty useful when you are not sure what you are going to use in the end, but, what if you are? You end up with lots of wasted space.

To reduce your database size, there are two ways you can go about it, revision control and database cleaning. To be honest, you should do both. Revision control just limits the number of posts revisions WordPress will store, so database cleanup is the smarter way to go.

You will also save a lot of space by optimizing the database after deleting revisions.

Old Posts

Your website’s 10th anniversary is getting closer. It’s your 3000th post, and everyone is excited. While you are celebrating, the hidden posts and pages you already forgot about are still somewhere in the database. Yeah, nostalgia is a warm and fuzzy feeling, but know that those posts take space. If you really want to keep them, do so on your local drive. To clean them, read ahead.

Unused Media

Images, songs and any other media file you are not using are absolutely unnecessary. This plugin will help you delete unused data in no time. 

Media Cleaner optimizes database

In addition, image optimization can improve performance of your WordPress sites a lot.

You should also update all your plugins and themes regularly. This can prevent some errors and help with optimization.

Caching Plugins

You can prevent the database from bloating by using the WordPress cache plugin like WP Rocket. With caching plugins you can set up WordPress to just keep certain data, or to limit how much of it to store. Yes, the caching is there to lower loading time, but that is not always the case. Web hosts have limits on their servers, that you should not cross. Besides, you can just use a faster WordPress theme if you need speed.

If you are using a more expensive WordPress hosting, there is a chance that WordPress cache will already be set up and optimized.

Always Back Up!

Even though the database clean up shouldn’t mess up your files, it’s always better to be safe than sorry. We won’t dive deep into backing-up methods in this tutorial, but you can read the complete guide here and here.

Clean Up WordPress Database Techniques

There are several ways you can choose to clean your WordPress database. Using an SQL query is the most direct approach, but we only recommend this method to advanced users. You can also hire a team of professionals to do it for you.

In this beginner’s guide, we will show you the easiest and fastest way. So, let’s try some plugins out.

Advanced Database Cleaner

This database plugin has 50.000 active installations, a great score, and fairly frequent updates. What we like about it, is that it can clean up WordPress database and also optimize it. In addition, there are plugins options for removing certain data that can be of use to advanced users. 

Advanced database cleaner plugin for WordPress

This plugin can help you clean WordPress database from:

  • Orphaned data
  • Unused tags
  • Auto drafts
  • Spam
  • Deleted Comments
  • Orphaned post meta
  • Revisions
  • Old posts
  • Pending comments etc.

It’s pretty straight forward. After you install and activate it, its interface will pop up. In the “General clean-up” tab check the data you want to “clean”. On the right side, you will see the amount of unnecessary data from each category.

Advanced Database Cleaner database cleanup

It will then inform you about backing up, but you did it, right? We’ve put it in big bold letters, no excuses!

Cleaning up database for improved performance

Your database is all cleaned up! Now we need to optimize it. To optimize the database after deleting excess data, move to the “Optimize” section, and choose what you need.

Advanced Database Cleaner Database Optimizer

Great, your site is now in pretty good shape! You can also schedule the next cleanup or optimization, which is an excellent option to have!

WP Optimize

What is great about the WP-Optimize plugin is that by being a part of Team Updraft, it also includes backup. 800k active installations also prove that what they are doing is great! Additionally, it comes with constant updates.

WP-Optimize Plugin For WordPress

Just like the aforementioned plugin, this one is also easy to use. Whether you want to optimize or clean your database one step at a time or all at the same time, it’s up to you.

 Advanced Db

Another amazing thing is that it also provides image optimization/compression options.

 sql

It is free to some extent, but the premium version unlocks all of its possibilities.

Honorable mentions: WP Clean Up Optimizer (similar to WP-Optimize plugin). This database optimizer optimizes the database just as good as the other two but includes fewer options.

Bonus tip of the day

If you are looking to up your WordPress security malware scanner, Wordfence Security plugin can be of great service.

Clean Up WordPress Database – Conclusion

You must admit that the cleaning database isn’t hard, yet it greatly improves site performance. We recommend making WordPress databases cleanup (and optimizing your WordPress database) a habit from now on. For more WordPress news, WordPress tips, and WordPress tutorials, check our blog out. Plus, if you have any questions we are here to help!

More Resources: