Best Way to Clean WordPress Database (Safe Step-by-Step)
Introduction
Open phpMyAdmin on a WordPress site that has run for three or four years. You will usually find the same mess. Thousands of post revisions pile up. Spam comments sit untouched. Expired transients linger, and plugins you removed long ago leave tables behind.
None of this shows on the front end. Yet every backup copies it, and every page load can query it. That is why the best way to clean a WordPress website database matters more than most site owners think. A bloated database slows the admin panel and inflates backups. It can also stretch your Time to First Byte and hide problems such as runaway cron jobs.
This guide shows you how to fix that without breaking your site. First, you will learn what fills a database. Next, you will see the cleanup method I recommend and how to install and use it. After that, you will find a comparison of the top five database cleaner plugins and a clear answer on free versus Pro. A manual route is included for people who prefer to skip plugins. If you would rather hand the job to someone else, there is a section for that too.
[Image Placeholder: Image: Bloated WordPress database tables listed by size in phpMyAdmin]
Why Your WordPress Database Gets Bloated
WordPress stores almost everything in MySQL. That includes posts, comments, settings, menus, and plugin options. This design is convenient. However, it also means every plugin you have tried can leave something behind.
The Usual Suspects
- Post revisions. WordPress saves a new copy each time you click Update. An article edited twenty times leaves twenty copies.
- Auto-drafts and trashed posts. WordPress creates these while you edit, and nobody removes them.
- Spam and trashed comments. Sites with open comments collect these quickly.
- Expired transients. These temporary cached values should vanish on schedule. Sometimes they do not.
- Orphaned meta and options. This is data whose parent post, user, or plugin no longer exists.
- Leftover plugin tables. Many plugins keep their tables after you uninstall them.
- Action Scheduler logs. WooCommerce and other plugins pile these up quietly.
What a Bloated Database Costs You
A big database does not always make a site feel slow. Even so, the costs add up. Backups take longer and use more storage. Queries on large wp_postmeta and wp_options tables slow down, especially on shared hosting. Large autoloaded options also load on every request, whether the page needs them or not.
Before you clean anything, find out where the weight sits. In phpMyAdmin, sort your tables by size. Two or three tables often account for most of the total.
What Is the Best Way to Clean a WordPress Database?
My answer is simple. Use a dedicated cleanup plugin that previews items before it deletes them, and take a full backup first. Manual SQL works for people who know what they are doing. For everyone else, a reliable plugin offers previews, scheduling, and a much safer path.
Plugin vs. Manual Cleanup
| Approach | Safety | Speed | Skill needed | Best for |
|---|---|---|---|---|
| Cleanup plugin | High (previews, filters) | Fast | Beginner | Most site owners |
| phpMyAdmin / SQL | Low to medium | Slow | Advanced | Developers |
| WP-CLI | Medium | Very fast | Advanced | Users with server access |
| Professional service | High | No effort from you | None | Busy owners, complex sites |
Among plugins, I point most people to Advanced Database Cleaner. It is free to start with. It shows what it will remove and how much space you will recover before you commit. Its free version also handles scheduling. The WordPress.org listing shows 100,000+ active installations and a 4.9-star average. The latest version I checked (4.2.0) was updated in July 2026 and tested with current WordPress releases.
The Rule That Overrides Everything Else
Back up your database and files first. Every reputable cleanup plugin says so, and they mean it. A deleted table does not come back on its own.
[Image Placeholder: Image: Advanced Database Cleaner General Cleanup screen showing items and total size to be freed]
Top 5 WordPress Database Cleaner Plugins
I list these in the order I would consider them for a typical business or blog site. Pricing changes often, so confirm each price on the vendor’s site before you buy.
1. Advanced Database Cleaner (My Top Pick)
Its free version covers the widest range of cleanup. It removes revisions, auto-drafts, trashed posts, spam and pending comments, pingbacks, and trackbacks. It also clears unused and duplicated meta, expired transients, and oEmbed caches. On top of that, it has dedicated modules for tables, options, cron jobs, post meta, user meta, transients, and post types.
Here is what stands out:
- It shows the space you will free, item by item, before you clean.
- Scheduled cleanup, optimization, and repair run hourly, daily, weekly, or monthly.
- A “keep last X days” rule protects recent data.
- It flags oversized autoloaded options, a common cause of slow admin pages.
- Version 4.2.0 added free WooCommerce tools for orphaned product variations, orphaned customer analytics, and expired customer sessions.
- Multisite is supported, with network-wide cleanup from the main site.
Downside: Orphan detection sits in the Premium version. That feature tells you which plugin owns a table or option. The interface is also denser than simpler tools, so beginners may need a few minutes to find their way around.
[Affiliate Link: Advanced Database Cleaner Pro]
2. WP-Optimize: Best All-in-One Option
WP-Optimize handles database cleanup, image compression, and page caching from one dashboard. It has over a million active installations. Its database tools are the oldest part of the plugin, and they cover most of what a typical blog or business site needs.
What It Cleans (Free Version)
- Post revisions and auto-draft posts
- Trashed posts
- Spam, trashed, and unapproved comments
- Expired transient options
- Pingbacks and trackbacks
- Orphaned post, user, and comment metadata
- Orphaned relationship data
- Database table overhead
How to Install It
- Go to Plugins → Add New and search for WP-Optimize.
- Click Install Now, then Activate.
- Open WP-Optimize → Database → Optimizations.
How to Clean Your Database With It
- Back up first. If UpdraftPlus is installed, a “Take a backup with UpdraftPlus before doing this” checkbox appears above the cleanup options.
- Tick the items you want to remove. Go easy on orphaned metadata until you see what it contains. WP-Optimize warns you before some of the riskier actions.
- Click Run all selected optimizations. This usually takes a few seconds to a minute.
- Open the Tables tab, pick a table, and click Optimize to reclaim overhead.
- To automate, go to Settings → Scheduled clean-up settings, click Add schedule, pick your tasks, and choose a frequency.
Two “Power tweaks” under the Database tab deserve a mention. One adds an index to the postmeta table to speed up meta searches. The other swaps a slow WooCommerce “total spent” query for two faster ones. Stores with many customers benefit most.
Free vs. Premium
| Feature | Free | Premium |
|---|---|---|
| Revisions, spam, transients, orphaned meta | Yes | Yes |
| Scheduled clean-ups | Yes | Yes, with exact date/time and separate schedules per task |
| Optimize all tables | Yes | Yes |
| Optimize individual tables | No | Yes |
| Delete unused images | No | Yes |
| Multisite support | No | Yes |
| Premium support | No | Yes |
Premium starts at about $49 for one year, as listed on the vendor’s site at the time of writing.
Pros and Cons
Pros: The layout suits beginners. Scheduling is built into the free version. The UpdraftPlus backup link saves time, and caching and image tools live in the same plugin.
Cons: The cache feature can conflict with a separate caching plugin. If you already use one, switch WP-Optimize’s cache off. It also offers fewer tools than Advanced Database Cleaner for tracking down orphaned tables and options.
Best for: Site owners who want one plugin for cleanup, caching, and image compression.
[Image Placeholder: Image: WP-Optimize Database → Optimizations tab with cleanup checkboxes]
[Affiliate Link: WP-Optimize Premium]
3. WP-Sweep: Best Free Option for a Simple One-Off Cleanup
Lester Chan wrote WP-Sweep, and it has been around for years. It does one job well. It finds rows WordPress leaves behind and removes them. There is no upsell and no license key.
Its deletion method sets it apart. Wherever possible, it calls WordPress’s own functions, such as wp_delete_post_revision(), wp_delete_post(), and wp_delete_comment(). It avoids raw SQL. Those functions fire the usual WordPress hooks, so related data tends to be cleaned up properly. Only orphaned meta with an object ID of 0 is deleted directly, because the API refuses to touch it.
What It Sweeps
- Revisions and auto-drafts
- Deleted posts
- Unapproved, spam, and deleted comments
- Orphaned post, comment, user, and term meta
- Orphaned term relationships and unused terms
- Duplicated post, comment, user, and term meta
- Transient options and oEmbed caches stored in post meta
- Table optimization
How to Install and Use It
- Go to Plugins → Add New, search for WP-Sweep, then install and activate it.
- Open Tools → Sweep.
- Take a backup. Every sweep is irreversible, and the plugin says so.
- Read each item’s description. The screen also shows a count and the share of its table those rows take up.
- Click Sweep next to one item, or use Sweep All once you feel comfortable.
- Run the table optimization step last.
WP-CLI users get a handy shortcut. Run wp sweep --all for everything, or wp sweep revisions for a single item. I found no built-in scheduler in the plugin’s documentation. For recurring runs, pair the CLI command with a server cron job.
Compatibility warning: The plugin’s documentation lists tools whose data WP-Sweep may treat as orphaned. These include WPML, Polylang, Slider Revolution, Meta Slider, and Elementor Popup Builder. If your site uses any of them, add their meta keys to the plugin’s exclusion filters before you sweep. Otherwise, choose a different tool.
Free vs. Pro: There is no Pro version. Everything is free.
Pros: It is free with no catch. It uses native WordPress delete functions, it is quick to understand, and it supports WP-CLI.
Cons: The interface has no built-in scheduling. It does not show options, cron jobs, or leftover tables. The compatibility caveats above also apply.
Best for: Small to mid-size sites that need a quick, careful sweep, plus developers who like command-line cleanups.
4. Database Cleaner by Meow Apps: Best for Finding Out Who Owns What
Meow Apps, the studio behind Media Cleaner and AI Engine, makes Database Cleaner. Its core idea is that deleting is easy, but knowing what is safe to delete is hard. Both the free and Pro versions try to show where each table, option, and cron job came from before you touch it.
One caution applies here. Most public comparisons come from the vendor’s own page. Meow Apps says so openly. Test the plugin yourself, and do not treat the marketing as the final word.
What It Offers
- Easy Mode reduces cleanup to one button for people who do not want to learn what a transient is.
- Expert Mode lists tables (with size and owner), options (with autoload flags), post types, and cron jobs.
- Ownership labels mark each item as WordPress core, an installed plugin, or nothing still running.
- Asynchronous processing splits heavy jobs into many small requests, according to the vendor. That helps on large databases and shared hosting, where one long request can hit the PHP time limit.
- Size tracking records database growth over time, so you can spot which plugin keeps adding data.
How to Install and Use It
- Go to Plugins → Add New and search for Database Cleaner by Meow Apps.
- Install and activate it, then open Meow Apps → Database Cleaner.
- Back up your database.
- For a quick job, stay in Easy Mode and follow the prompts.
- For more control, switch to Expert Mode and open the Tables tab. A table owned by a plugin you removed is a candidate for deletion. An unowned table deserves a second look first.
- Repeat for options and cron jobs. Sort the options list by size and autoload status.
Free vs. Pro
| Feature | Free | Pro |
|---|---|---|
| Easy Mode and Expert Mode | Yes | Yes |
| Ownership detection for core and common plugins | Yes | Yes, with a much larger curated map |
| Automatic sweeper (scheduled cleaning) | No | Yes |
| Extended ownership database | No | Yes (roughly 5,300 tables and 59,000 options, per the vendor) |
On the vendor’s page (checked in September 2026), Pro cost $39 per year for one site, $59 for five sites, and $99 for a professional tier. Lifetime licenses started at $249. Confirm current prices before you buy.
Pros: The free version shows useful ownership data. Easy Mode is gentle on beginners, and the design targets large databases.
Cons: Scheduled cleanups cost extra. The plugin is newer than the others on this list, and its biggest claims come from the vendor.
Best for: Owners of older sites that have run many plugins and want to know what is left behind.
[Affiliate Link: Database Cleaner Pro]
5. Optimize Database after Deleting Revisions: Best for Revision-Heavy Blogs
The name says it all. This small, single-purpose plugin has been around since 2011. NerdPress adopted it in January 2024 to keep it maintained. If you have saved the same long articles hundreds of times, this plugin fixes that problem directly.
What It Does
- Deletes post revisions with precise controls
- Optimizes tables afterward, with an option to include InnoDB tables
- Removes transients, either only expired ones or all of them
- Runs on a schedule you choose
- Works on multisite, where one click optimizes every site in the network
Revision Controls Worth Knowing
- Delete revisions older than a set number of days, keep a maximum number per post, or combine both rules.
- Limit deletion to posts only, pages only, or both.
- Protect a single post or page with a custom field named
keep_revisionsset toY. Its revisions stay, whatever the other settings say.
How to Install and Use It
- Go to Plugins → Add New, search for Optimize Database after Deleting Revisions, then install and activate it.
- Open Settings → Optimize Database.
- Back up your database.
- Choose how many days of revisions to keep, or set a maximum per post.
- Decide whether to include transients and InnoDB tables.
- Go to Tools → Optimize Database and click Start Optimization. The plugin shows how much space it freed.
- Set a schedule on the settings page if you want to automate it.
Free vs. Pro: It is entirely free, with no paid version.
Pros: It offers fine-grained revision rules, the keep_revisions safety switch, multisite support, and a very light footprint.
Cons: It never touches orphaned options, cron jobs, or leftover plugin tables. The last release I could verify dates from April 2024, so check compatibility with your WordPress and PHP versions first.
Best for: Content-heavy blogs, news sites, and editorial teams that revise posts often.
Quick Comparison
[Image Placeholder: Image: Side-by-side comparison chart of the top 5 WordPress database cleaner plugins]
| Plugin | Price | Key features | Pros | Cons | Best for |
|---|---|---|---|---|---|
| Advanced Database Cleaner | Free; Premium from roughly $39/yr | Previews, scheduling, tables/options/cron modules, autoload checks | Deep cleanup in the free version, 4.9★ on WordPress.org | Orphan detection is Premium; denser UI | Most sites, agencies, WooCommerce |
| WP-Optimize | Free; Premium from roughly $49/yr | Cleanup, caching, image compression | All-in-one, huge user base | Extra features you may not need | Owners who want one plugin |
| WP-Sweep | Free | Revisions, drafts, orphaned meta, transients | Simple, uses WordPress delete functions | Limited automation | Quick one-off cleanups |
| Database Cleaner (Meow Apps) | Free; Pro paid | Ownership detection for tables/options/cron | Shows what belongs to what | Automatic sweeper is Pro | Cautious cleaners |
| Optimize Database after Deleting Revisions | Free | Revision cleanup plus table optimization | Very simple | Narrow scope | Revision-heavy blogs |
Which One Should You Pick?
- One tool for everything, including caching? Choose WP-Optimize.
- Deep cleanup of tables, options, and cron jobs? Choose Advanced Database Cleaner.
- A free, careful sweep done once? Choose WP-Sweep.
- Clear ownership for every leftover table? Choose Database Cleaner by Meow Apps.
- Only fighting post revisions? Choose Optimize Database after Deleting Revisions.
Would you rather not test them one by one on a live site? We can pick the right tool, run the cleanup, and test your site afterward.
👉 Contact Sarbd for Database Cleaning
How to Install Advanced Database Cleaner
The plugin installs like any other from the WordPress directory. Three methods work.
Method 1: From the Dashboard (Easiest)
- Log in to your WordPress admin.
- Go to Plugins → Add New.
- Search for Advanced Database Cleaner.
- Click Install Now, then Activate.
- Find it under Dashboard → DB Cleaner or Tools → DB Cleaner, depending on your settings.
Method 2: Upload the ZIP
- Download the plugin from WordPress.org.
- Go to Plugins → Add New → Upload Plugin.
- Choose the ZIP file and click Install Now.
- Activate it from the Plugins screen.
Method 3: FTP
Unzip the download. Next, upload the advanced-database-cleaner folder to /wp-content/plugins/. Then activate it from the Plugins page.
Multisite Note
Install and network-activate the plugin from the primary site. Only the main site can run network-wide cleanup. This rule stops subsite admins from deleting shared data by accident.
Before You Click Anything
Make a backup. Use your host’s snapshot tool, UpdraftPlus, or a phpMyAdmin export. Then confirm the backup file exists and has a sensible size.
How to Clean Your WordPress Database Step by Step
Here is the order I follow on client sites. It saves the risky items for last.
Step 1: Run the General Cleanup Preview
Open the General Cleanup tab. Each item type appears with a count and an estimated size. Click the preview on any item to see exactly which rows will go.
Step 2: Start With the Safe Categories
Clean these first:
- Auto-drafts
- Spam and trashed comments
- Expired transients
- Old post revisions
For revisions, set a “keep last X days” rule so recent edits stay available. When a client is mid-edit on a big article, I leave the last few weeks alone.
Step 3: Handle Orphaned and Duplicated Meta
Unused meta rows point at posts, users, comments, or terms that no longer exist. Duplicated meta repeats the same key and value for one post or user. Use the preview to confirm each item before you delete it.
Step 4: Review Tables, Options, and Cron Jobs
This step needs more care. In the Tables tab, look for invalid prefixes or names you recognize from removed plugins. In Options, sort by size and check autoload status. A few large autoloaded options can add real weight to every request. In Cron Jobs, look for tasks with no valid action. The plugin’s FAQ advises against deleting any cron job you cannot identify.
The free version cannot tell you which plugin owns an item. In that case, search the item’s name online, or leave it alone.
Step 5: Optimize and Repair Tables
After deleting rows, optimize your tables to reclaim space. The plugin notifies you when a table needs optimization or repair.
Step 6: Schedule It
Create a scheduled task so you never repeat this by hand. A weekly revision and transient cleanup, plus a monthly optimization, suits most sites. The free version allows up to five automation tasks.
Step 7: Check Your Site
Load the front end and test your forms. Check checkout if you run WooCommerce, and look over the admin dashboard. If anything seems wrong, restore the backup.
[Image Placeholder: Image: Scheduled cleanup task setup in Advanced Database Cleaner with a “keep last 30 days” rule]
Free vs. Pro: What You Actually Get
The free version handles routine cleanup well. Premium pays off when you want to find and remove leftovers from deleted plugins with confidence.
| Feature | Free | Premium |
|---|---|---|
| Revisions, drafts, spam, trash, transients cleanup | Yes | Yes |
| Preview items and size before cleaning | Yes | Yes |
| “Keep last X days” rule | Yes | Yes |
| Scheduled cleanup and optimization | Yes (up to 5 tasks) | Unlimited tasks |
| Table optimize, repair, and InnoDB conversion | Yes | Yes |
| Autoload and large-option detection | Yes | Yes |
| WooCommerce cleanup tools | Yes | Yes |
| Orphaned tables, options, meta, transients, cron jobs | No | Yes |
| Remote SmartScan ownership detection | No | Yes |
| Keep last X items (for example, 5 revisions per post) | No | Yes |
| Action Scheduler cleanup | No | Yes |
| Advanced filters across modules | No | Yes |
| Database analytics and growth charts | No | Yes |
| Addons Activity timeline | No | Yes |
| Per-task automation logs | No | Yes |
Which Should You Choose?
Stay on free if you run a blog or small business site. It fits you if you mainly want revisions, spam, and transients gone, and you are happy to leave unknown tables untouched.
Consider Premium in three situations. You may have installed and removed many plugins over the years. You may run WooCommerce, where Action Scheduler tables grow quickly. Or you may manage several client sites and want to watch database growth over time.
[Affiliate Link: Advanced Database Cleaner Premium]
Cleaning Your Database Manually (For Advanced Users)
You do not need a plugin, but you do need care. Always back up first.
Option 1: phpMyAdmin
This query removes revisions. Replace wp_ with your actual table prefix.
DELETE FROM wp_posts WHERE post_type = 'revision';
Orphaned metadata usually remains afterward:
DELETE pm FROM wp_postmeta pm
LEFT JOIN wp_posts p ON p.ID = pm.post_id
WHERE p.ID IS NULL;
Run both on a staging copy first. A wrong WHERE clause can wipe real content.
Option 2: WP-CLI
With SSH access, WP-CLI is quicker and safer than hand-written SQL:
wp transient delete --expired
wp db optimize
Option 3: Limit Revisions Going Forward
Add this line to wp-config.php to cap saved revisions per post:
define( 'WP_POST_REVISIONS', 5 );
When Manual Work Is Not Worth It
Hand-editing tables saves a few dollars but costs time. A single mistake can also take a site offline. Suppose your database has hundreds of tables, a messy WooCommerce history, or leftovers from many removed plugins. In that case, paying a specialist is often cheaper than a bad afternoon.
Tips, Dos and Don’ts for Safe Database Cleaning
Do
- Take a full backup and confirm you can restore it.
- Clean a staging copy first if the site earns money.
- Use previews and the “keep last X days” rule.
- Schedule recurring cleanups so bloat never builds up.
- Re-check autoloaded options every few months.
- Cap revisions in
wp-config.php.
Don’t
- Delete tables just because you do not recognize the name. Some belong to active plugins or themes.
- Remove core WordPress tables or options.
- Run two cleanup plugins at the same time.
- Clean cron jobs you cannot identify.
- Skip testing the site afterward.
Need a Hand? We’ll Clean It for You
Maybe you would rather not risk your live site. Our team at Sarbd handles database backup, cleanup, optimization, and testing at an affordable price. We will also tell you exactly what we removed.
👉 Contact Sarbd for Database Cleaning
[💬 Chat on WhatsApp: Click to Message Us]
Frequently Asked Questions
What is the best way to clean WordPress website database?
Back up first. Then use a plugin with previews, such as Advanced Database Cleaner, to remove revisions, spam, transients, and orphaned data. Afterward, schedule the routine jobs so clutter does not return.
Is it safe to clean a WordPress database?
Yes, as long as you back up first and delete only items WordPress considers unnecessary. The risk comes from removing tables, options, or cron jobs you cannot identify.
How often should I clean my WordPress database?
For most sites, a weekly cleanup of revisions, spam, and transients works well. Add a monthly table optimization. High-traffic stores and sites that publish daily may need more frequent runs.
Does cleaning the database speed up my website?
It can help, particularly on older or busy sites with large tables or oversized autoloaded options. However, it will not fix a slow host or heavy images. Treat it as one part of your performance work.
What is the difference between the free and Pro versions of Advanced Database Cleaner?
The free version covers standard cleanup, previews, scheduling, and table tools. Premium adds orphan detection, Remote SmartScan ownership data, “keep last X items,” Action Scheduler cleanup, advanced filters, and analytics.
Can I clean my WordPress database without a plugin?
Yes. You can use phpMyAdmin queries or WP-CLI. Developers who know the schema will find this quick. Still, one mistyped query can delete real content, so test on a copy first.
Which database cleaner plugin is best for WooCommerce?
Advanced Database Cleaner includes free tools for orphaned product variations, customer analytics, and expired sessions. Its Premium version also clears Action Scheduler logs, which grow fast on active stores.
Conclusion
A tidy database means smaller backups, a faster admin, and easier troubleshooting. The best way to clean a WordPress database comes down to a few habits. Back up first. Preview before you delete. Start with low-risk items such as revisions and expired transients. Finally, schedule the routine work so it stays done.
For most sites, Advanced Database Cleaner is the place to begin. The free version covers daily housekeeping, and Premium is ready when you need orphan detection or deeper automation. WP-Optimize suits people who want caching and image tools alongside cleanup. Meanwhile, WP-Sweep and the revision-focused plugin handle lighter jobs.
Ready to start? Install the plugin, take that backup, and run your first preview today.
[Affiliate Link: Advanced Database Cleaner Pro]
If you would rather skip the technical side, we will do it for you at a fair price. Send us a message, and we will check your site first.
[💬 WhatsApp Button: Chat With Us Now]