WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Plugins» How to Clean Up Your WordPress Database for Improved Performance

How to Clean Up Your WordPress Database for Improved Performance

Last updated on May 5th, 2015 by Editorial Staff
560 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
How to Clean Up Your WordPress Database for Improved Performance

If you have been using WordPress for a while, then there is a good chance that you need to clean up your WordPress site. Doing regular clean ups allow you to reduce your database size which means quicker and smaller backup files. In this article, we will show you how to clean up WordPress database.

Cleaning up WordPress Database

As you use WordPress, your database accumulates a lot of extra data such as revisions, spam comments, trashed comments, data from plugins you are no longer using, and more. Removing all this unnecessary data can significantly reduce your database size which speeds up your backup process and can add minor performance improvements as well.

Let’s take a look at how you can clean up your WordPress database.

Before you start, Make a Backup!

Before you do anything else, first create a complete WordPress backup of your site. Changes made by the clean up plugin are irreversible. Even though it does not directly mess with your posts or comments, its always better to be safe than sorry.

Video Tutorial

Subscribe to WPBeginner

If you don’t like the video or need more instructions, then continue reading.

Cleaning up your WordPress Database with WP-Sweep

First thing you need to do is install and activate the WP-Sweep plugin. Upon activation, simply go to Tools » Sweep to clean up your WordPress database.

WP-Sweep posts analysis

This plugin will analyze your WordPress database and show you a report of how much clutter you can clean. The sweep report is divided into different sections for your posts, comments, user meta, options, terms, and database optimize.

Cleaning up your comment meta and user meta data

You can go through items and clean them individually, or you can scroll down to the bottom of the page and click sweep all to clean up everything in your WordPress database.

Cleaning up may take some time depending on how big your database is. WP-Sweep will show you the progress by updating the stats on the page.

Why WP-Sweep vs WP-Optimize?

You may be wondering why are we writing about WP-Sweep when there is a very popular WP-Optimize plugin available that does nearly the same thing.

Well that’s because it’s coded by a well-respected WordPress developer, Lester Chan.

Also because the main distinguishing characteristic of WP-Sweep is that it uses proper WordPress delete functions as much as possible instead of running direct delete MySQL queries. Whereas the WP-Optimize plugin uses direct delete SQL queries which can leave orphaned data left behind.

Looking through WP-Optimize and they are using SQL query to delete post revisions which means there will be orphaned data left behind.

— Lester Chan (@gamerz) February 23, 2015

In other words, WP-Sweep is a better coded plugin than WP-Optimize.

What all does WP-Sweep clean?

WP-Sweep uses all the proper WordPress delete functions to clean up the database. At the time of writing this article, it can clean up the following:

  • Revisions
  • Auto drafts
  • Deleted comments
  • Unapproved comments
  • Spammed comments
  • Deleted comments
  • Orphaned post meta
  • Orphaned comment meta
  • Orphaned user meta
  • Orphan term relationships
  • Unused terms
  • Duplicated post meta
  • Duplicated comment meta
  • Duplicated user meta
  • Transient options
  • Optimizes database tables
  • oEmbed caches in post meta

That’s all, we hope this article helped you clean your WordPress site using WP-Sweep. You may also want to check out our guide on the most common WordPress errors and how to fix them.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Google+.

560 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • How to Properly Move Your Blog from WordPress.com to WordPress.org

  • Google Analytics in WordPress

    How to Install Google Analytics in WordPress for Beginners

  • How to Fix the Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

  • Revealed: Why Building an Email List is so Important Today (6 Reasons)

    Revealed: Why Building an Email List is so Important Today (6 Reasons)

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

25 Comments

Leave a Reply
  1. Ed says:
    Jan 7, 2021 at 3:38 am

    What a fantastic plugin. Has made such a difference to my website and increased the speed by a lot

    Reply
    • WPBeginner Support says:
      Jan 7, 2021 at 9:55 am

      Glad our recommendation was helpful :)

      Reply
  2. Nivesh Gandhi says:
    Sep 15, 2018 at 1:27 am

    Both are great plug ins. Normally you don’t even need to do backup. But its always good to be on safe side.

    Reply
  3. Dave says:
    Aug 29, 2017 at 6:46 am

    WP Sweep – what a plugin. I have a WP site that hadn’t had much love over the past 18 months and somehow had a 1.4Gb DB. Worryingly WP Sweep managed to reduce that to just over 17MB.

    More investigation needed.

    Reply
  4. Francis says:
    Jun 26, 2017 at 7:28 am

    Hello , i have a question. Im using godaddy managed wordpress . They have a staging site. Can i use the staging site to clean up database then , push it to live production site after. Will it clean my database. Thanks

    Reply
  5. Jules says:
    Feb 21, 2017 at 4:40 am

    2017 update? anyone else sharing their experience? Usability ?

    Reply
  6. Francisco Martínez says:
    Dec 21, 2016 at 1:40 pm

    Thank you!

    Reply
  7. Mike Patterson says:
    Nov 26, 2016 at 3:57 am

    Thank you for the useful information on cleaning WordPress Site. This helps me a lot as my site is getting bulky and take a lot of time to get load.

    Reply
  8. Jan says:
    Oct 24, 2016 at 5:38 am

    The absence of scheduling is a major disadvantage

    Reply
  9. Ramon says:
    Mar 14, 2016 at 6:07 pm

    Looked promissing but I’m not sure about the result. I had about 2600 revisions.. hoped cleaning them would make a difference but it didn’t, at least not in database size, might even be bigger now .. about 800MB.. What options are there to compact database if cleaning up doesn’t help?

    By the way: looked like wp-sweep locked up a couple of times.. after refesh I noticed that the numbers were decreased and I started again, and again, and again till all revisions where removed. Can’t say I’m excited about wp-sweep but maybe I used it wrong, is that possible?

    Reply
  10. Ahmed says:
    Dec 23, 2015 at 1:06 pm

    Very nice post!
    Cleaning database is very usefull especially for large ones.
    I have used the Advanced Database Cleaner, it is also very powerful and provides many features such as scheduling the cleaning of database and more…

    Reply
  11. Chris says:
    Nov 24, 2015 at 3:19 pm

    I really enjoyed this article, the layout, and the links. I really just had to say I appreciate the 50 second video that quickly and easily explained what to do and the lead in of backing up your site with a quick little article to find a backup service. I’m new to WP and blogging but trying to learn fast and after viewing this page I can tell I’m going to be spending a lot of time on your site! Well done and thanks!

    Reply
  12. Gerard says:
    Apr 27, 2015 at 2:51 am

    Nice job .. on article and plugin … Are the WP-Sweep commands visible under WP-CLI?

    Ta!

    Gerard.

    Reply
  13. Anna says:
    Apr 26, 2015 at 12:55 pm

    I had wp optimize on my “to install” list, but after seeing this post I downloaded WP sweep. it’s so easy to use. I usually clean up my spam comments, but I know that I have a lot of revisions on my posts so it’s good to get rid of those!

    Reply
  14. Bhongo says:
    Apr 26, 2015 at 12:27 pm

    yet another great article. Good job guys, I have never thought about about a database clean-up for my WP sites but now thanks to you, I will be doing a clean-up ASAP.

    Reply
  15. Nikky says:
    Apr 24, 2015 at 9:39 am

    We’ve been using Wp-Optimize plugin and it works great with similar options to the plugin mentioned above. What you suggest Wp-Optimize or WP-Sweep ?

    Reply
  16. Lester Chan says:
    Apr 24, 2015 at 1:55 am

    Thanks for the review =)

    Reply
    • WPBeginner Support says:
      Apr 24, 2015 at 4:37 pm

      Thanks for writing and sharing such useful plugin with the community.

      Reply
  17. BDorin says:
    Apr 23, 2015 at 11:24 pm

    Great and really easy to use but before make a back-up it is very important.

    Reply
  18. KennyTheMap says:
    Apr 23, 2015 at 6:00 pm

    Certainly cleaned up a lot of trash from my main website.
    Like Broken Link Checker it is a really useful plugin.

    A question; I deactivate such plugins until I next need to use them as I gather that can improve performance. Is my assumption correct?

    Thanks, Kenny

    Reply
    • WPBeginner Support says:
      Apr 24, 2015 at 4:44 pm

      Properly coded plugins will not affect your site’s performance when you are not using them. But there can be plugins that will add additional style sheets or JavaScript even if you are not using them. So it is best to deactivate the plugins you are not using.

      Reply
  19. Marcelo says:
    Apr 23, 2015 at 1:07 pm

    Whoa! I’ll be switching almost right now, unless the author of WP-Optimize upgrade its plugin this week :)

    Reply
  20. Dave says:
    Apr 23, 2015 at 11:50 am

    I agree! I have used a bunch of tools for this purpose before, with mostly good results. But this plugin is SO much easier to use, and really did a great job of cleaning.

    Of course, some people won’t heed the clear warning to back up first, but that’s human nature, I suppose. :)

    A super job by Lester Chan, an under-appreciated outstanding coder and contributor to WordPress!

    Dave

    Reply
  21. Kenneth Adair says:
    Apr 23, 2015 at 11:31 am

    I deleted the wp-optimize and added the wp-sweep but where does one see what the database size is before and after sweeping?

    Reply
    • Marcelo says:
      Apr 27, 2015 at 8:46 pm

      That’s the thing with this Sweep plugin. Its author wants things clear, simple, and minimalistic. But I think the UI for such a critical tool like a database cleaning, should be more detailed.
      Also, the lack of a scheduling feature will make it pass unnoticed.

      I think the best approach would be if Ruhani Rabin could upgrade its own and well known plugin to use official, native, WP queries to the cleaning. I will ask him what does he think about it.
      https://github.com/ruhanirabin/WP-Optimize/issues/60

      Lester Chan is a great programmer, but I wouldn’t like to abandon WP-Optimize because of the approach.

      What do you think guys?

      Best regards

      Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
TrustPulse
TrustPulse
Instantly get 15% more conversions with social proof. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2020 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2020)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2020)
    • SiteGround Reviews from 4196 Users & Our Experts (2020)
    • Bluehost Review from Real Users + Performance Stats (2020)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2020 – Step by Step Guide
Deals & Coupons (view all)
WPForms Logo
WPForms Coupon
Get 50% off WPForms, the most beginner friendly WordPress contact form plugin available in the market.
Complianz
Complianz GDPR Coupon
Get 15% OFF on Complianz GDPR premium WordPress privacy suite plugin.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).
Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress CDN by MaxCDN | WordPress Security by Sucuri.