Knowledgebase Home / Clean and Optimize a WordPress Database

Clean and Optimize a WordPress Database


In this KB Article, we discuss the importance of keeping your WordPress database(s) optimized and clean. The WordPress database stores everything that you need for your website and many things that you don’t.

What can affect database performance?

The frequent addition, deletion and moving data in the database that WordPress uses can make it inefficient. Even though we have an “optimize database” option in cPanel, it is not done automatically.

Every time a new post or page is created or an existing page is edited, WordPress creates a revision of that page or post. It is basically a copy of the contents and is kept in the database even after you publish the post or page. For. e.g. if you edit a post 5 times, you might have 4 copies of that post as revisions. This quickly adds a lot of rarely-used data to the tables, making them unnecessarily bloated and results in slower access times. There may also be a lot of spam and unapproved comments in your comments table which takes your valuable space further slowing down load times.

Even after deleting a plugin/theme from your WordPress website, they can still leave data in the database such as orphaned options, tables, and cron tasks. Not all plugins and themes are good at “leave no trace” after removing them. If you love trying out new themes and plugins frequently, the leftovers will pile up and start influencing the website’s performance.

What can we do?

We need to clean up the database by taking steps like deleting orphaned items such as ‘old revisions’, ‘old drafts’, ‘spammed comments’ and optimizing the database to reduce the database size and improve website load speeds. Keeping the database smaller and optimized also helps to backup and restore databases without any errors.

Yes, keeping the database clean involves much manual work and requires knowledge of WordPress internals and MySQL queries. Fortunately, We have a lot of plugins that can clear out all of this unnecessary data, clean up the tables and retrieve space lost to data fragmentation. Below are some of them.

WP-Sweep

Advanced Database Cleaner

You can find more plugins from the WordPress plugin repository at https://wordpress.org/plugins

Please note that we do not endorse any of these plugins and they might have an incompatibility with other plugins/themes you use. Make sure that you take a backup of the MySQL database to your local machine before running these plugins.

As always, if you have any questions, don’t hesitate to contact us.

How useful was this post?

Click on a star to rate it!

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!


If the steps above listed in this article do not resolve your issue, please feel free to open a support ticket and we’d be happy to take a look. Looking for better web hosting? Sign up today and take 50% off your first month with promo code: 1stmonth50

Our Guiding Principles

  • Provide consistent, stable and reliable web hosting services.
  • Ensure rapid ticket response and quick resolutions to issues.
  • Never saturate or over-provision servers to ensure stability and speed for our customers.
  • Use only high quality enterprise-class hardware to ensure minimal downtime from hardware failures.
  • Provide clear pricing with no hidden fees or gotchas.