Introduction
Every post you publish, every revision you save, and every plugin you install leaves rows behind in your WordPress database. Over months and years, that clutter adds up: old revisions, spam comments, expired transients, and orphaned data from plugins you deleted long ago. If your admin area feels sluggish or your pages take longer to load, learning how to optimize WordPress database tables is one of the highest-impact fixes you can make, and it costs nothing.
This guide shows you how to optimize WordPress database tables safely, step by step. You will back up first, find out what is actually bloating your database, optimize WordPress database tables with a free plugin, and learn the manual method in phpMyAdmin for full control. You will also learn how to stop the bloat coming back, so a short monthly routine replaces a yearly rescue job.
You do not need to be a developer: the plugin method takes about fifteen minutes. Everything here was checked against the official WordPress plugin pages on 28 November 2026, so you can optimize WordPress database tables with confidence — follow the steps in order and do not skip the backup.
In this guide
- Before you optimize WordPress database tables: back up first
- What slows a WordPress database down
- How to optimize WordPress database tables with WP-Optimize
- How to optimize WordPress database tables manually in phpMyAdmin
- How to stop the bloat coming back
- WordPress database cleanup methods compared
- Frequently asked questions

Before You Optimize WordPress Database Tables: Back Up First
Cleaning a database deletes data permanently, so a wrong click can remove something you wanted to keep. The first step when you optimize WordPress database tables is always a fresh backup, taken minutes before you start.
Use a backup plugin such as UpdraftPlus, or your host’s backup tool, and make a full backup that includes both the database and your files. Download a copy to your own computer too, and confirm the backup exists with a recent timestamp before you touch anything.
If your host offers a staging site, do the first cleanup there: it shows exactly what each step frees and whether anything breaks, with zero risk to your live site. Without staging, pick a quiet time and keep the backup close. Never clean a live database without a way back.
What Slows a WordPress Database Down
A standard single-site WordPress installation uses 12 core database tables, all sharing the prefix wp_ by default. Your posts, pages, revisions, attachments, and menu items live in wp_posts. Extra data attached to them, such as featured images, page-builder layouts, and SEO fields, lives in wp_postmeta. Your settings, including transients and the list of active plugins, live in wp_options, while comments live in wp_comments and users in wp_users.
Most of that data earns its place. The problem is the data that does not. WordPress saves a revision every time you update a post, so a post edited twenty times carries twenty stored copies. Auto-drafts pile up from posts you started and abandoned, trashed posts and comments sit in the database until the trash is emptied, and spam comments accumulate by the thousand on popular sites. When you delete a plugin, its settings and tables often stay behind as orphans.
Two quieter culprits deserve attention. Transients are temporary cached values that plugins store in wp_options, and expired ones should disappear on their own but often do not. Autoloaded options are settings WordPress loads on every single page view, so a bloated autoload list slows down every request. Both cleanup plugins in this guide flag large autoloaded options as a performance problem.
How to check what is bloating your database
Open phpMyAdmin or your host’s database manager and look at the list of tables with their row counts and sizes. The biggest tables are usually wp_posts, wp_postmeta, and wp_options, and that tells you where to focus when you optimize WordPress database tables. A wp_postmeta table far larger than wp_posts points at a page builder or a plugin storing heavy data per post, while a large wp_options table points at transients and autoloaded settings. Taxonomy data used by features such as breadcrumbs lives in wp_terms and its related tables — see our guide to adding breadcrumbs to WordPress for how that data is used.
How to Optimize WordPress Database Tables With WP-Optimize
The simplest way to optimize WordPress database tables is WP-Optimize, a free plugin from TeamUpdraft, the team behind UpdraftPlus. Its plugin page on wordpress.org says it is trusted by more than 1 million WordPress website owners, and the free version covers everything in this guide: cleaning, scheduling, and table optimization. Premium adds multisite support and WooCommerce tweaks.
WP-Optimize cleans post revisions, auto-draft posts, trashed posts, spam comments, trashed comments, and expired transients, and it optimizes the tables themselves. It can also cache your site, compress images, and minify code, but use only the database tools here so you can see exactly what changed. Cleanups can run on demand or on a daily, weekly, fortnightly, or monthly schedule.
Step-by-step cleanup with WP-Optimize
- Install and activate WP-Optimize from Plugins > Add New in your WordPress admin, then open WP-Optimize > Database.
- Tick revisions, auto drafts, trashed posts, spam comments, trashed comments, and transient options — safe on almost every site.
- Leave the “optimize database tables” option ticked as well, then click Run optimization and note the space freed, which the plugin reports after each run.
- Open your site and click through a few pages to confirm everything still works.
- Set a schedule under the plugin’s settings: weekly for an active blog or store, monthly for a quiet brochure site.
Two details from the plugin’s FAQ: optimizing runs routine, well-defined MySQL commands, but the authors still recommend a backup before your first run. And if your tables use the InnoDB engine, the on-disk optimization step is not available, while cleanup still works normally — so do not be surprised if the space freed looks smaller than expected: the real win is the rows removed.
How to Optimize WordPress Database Tables Manually in phpMyAdmin
If you would rather not add another plugin, you can optimize WordPress database tables by hand in phpMyAdmin, which most hosts include in their control panel. Every action is direct, so follow the order below and do not improvise with delete queries.
Open phpMyAdmin, select your WordPress database, and confirm the table prefix matches your site — wp_ unless your installer changed it. The table list shows each table’s size and overhead, the wasted space left by deleted rows.
Optimize the tables
- Scroll to the bottom of the table list and tick Check all.
- From the “With selected” dropdown, choose Optimize table. phpMyAdmin runs the MySQL OPTIMIZE TABLE command on each table and reports the result.
- If the same tables keep showing overhead, something is deleting and rewriting rows constantly — a scheduled cleanup will serve you better than manual runs.
Delete old revisions by hand
Revisions are the biggest single source of bloat for blogs that edit posts heavily. In phpMyAdmin, open the SQL tab and run one query, after checking your table prefix:
DELETE FROM wp_posts WHERE post_type = 'revision';
That removes every stored revision while leaving published posts, pages, and attachments untouched. Run it only after your backup, and only if nobody needs to restore an old version of a post. If you are not comfortable running SQL, use the plugin method instead — the result is the same. Never delete rows from wp_options by hand unless you know exactly what an option does, because a wrong deletion there can break your site’s settings.
How to Stop the Bloat Coming Back
Cleaning once is satisfying, but the database starts growing again the next day — so after you optimize WordPress database tables, limit what gets stored in the first place. When you optimize WordPress database tables regularly, the monthly routine takes five minutes instead of an afternoon.
Start by limiting revisions. Add this line to wp-config.php, above the line that says “stop editing”: define( 'WP_POST_REVISIONS', 3 );. WordPress will then keep only the three most recent revisions of each post. If you edit collaboratively and rely on old revisions, set the number higher, but do not leave it unlimited on a busy site.
Next, delete plugins and themes you no longer use instead of leaving them deactivated. Deactivated plugins still leave their tables and settings behind, and some keep writing rows. After deleting a plugin, check the table list in phpMyAdmin for tables with its name and remove them only if you are certain they belong to that plugin. The same habit applies to design tweaks: instead of installing a new plugin for every small change, add custom CSS to WordPress directly, which stores nothing extra in the database.
Tracking and consent tools are another steady source of rows. Analytics and tag plugins write settings and cached data into wp_options, and consent banners can log entries with every visit, so review what they store and trim their retention settings. If you run tracking through a tag manager, see our guide to adding Google Tag Manager to WordPress, and for a consent banner, see our guide to adding a cookie consent banner to WordPress.
Finally, make it a habit: empty the trash regularly, run your cleanup on a schedule, and check the largest tables every few months. A table that grows suddenly usually means a plugin logging too much — fixing that plugin beats cleaning its output forever.
If your site is still slow after cleaning
A clean database removes one bottleneck, not every bottleneck. If pages still load slowly, look at image sizes, caching, and your hosting plan next — and check the browser console for mixed content warnings, which our guide to fixing WordPress mixed content errors walks through.

WordPress Database Cleanup Methods Compared
There is no single best way to optimize WordPress database tables — the right method depends on your comfort with technical tools. All four options below were checked against their official wordpress.org plugin pages on 28 November 2026.
| Method | Cost | Best for | Scheduling | Skill needed |
|---|---|---|---|---|
| WP-Optimize | Free, with a Premium version | Beginners who want cleanup, caching, and image compression in one plugin | Daily, weekly, fortnightly, or monthly | Low |
| Advanced Database Cleaner | Free, with a Premium version | Site owners who want detailed previews and orphan detection | Hourly, twice daily, daily, weekly, or monthly; free version limited to 5 tasks | Medium |
| WP-Sweep | Free | Developers who want cleanups done with proper WordPress delete functions | No built-in scheduler; run manually or by WP-CLI | Medium to high |
| Manual phpMyAdmin | Free | Full control with no extra plugin installed | None; run by hand when needed | High |
WP-Optimize is the best starting point for most sites: free, trusted by more than 1 million site owners, with a scheduler so the job happens without you.
Advanced Database Cleaner suits owners who want to see exactly what will be deleted first, including orphaned tables and options left by removed plugins — its Premium version adds orphan detection and analytics. WP-Sweep is the developer’s choice: it uses WordPress’s own delete functions so other plugins’ hooks still fire, and it offers WP-CLI and REST API control, but every sweep is irreversible and there is no settings screen. Manual phpMyAdmin work installs nothing, but it is the easiest way to make a mistake — leave deletions to a plugin unless you are confident with SQL.
Whichever method you pick to optimize WordPress database tables, the maintenance routine is the same: back up, clean, check the result, and schedule the next run. The tool matters less than the habit.
Who this is for: Learning how to optimize WordPress database tables pays off most for blogs and stores running for a year or more. Start with WP-Optimize on a weekly schedule, limit revisions to three, and check your largest tables every few months.
Verdict: A clean WordPress database is the cheapest speed win available: free tools, fifteen minutes, and a routine that runs itself afterwards. Back up first, clean the safe items, and keep revisions limited. Re-check how to optimize WordPress database tables yearly, since plugins and best practices change.
Frequently Asked Questions
Is it safe to optimize a WordPress database?
Yes, if you back up first and clean only the safe items: revisions, auto-drafts, trashed posts and comments, spam, and expired transients. WP-Optimize’s FAQ notes that optimizing runs routine MySQL commands, and still recommends a backup before your first run. Never delete rows from wp_options by hand unless you know what the option does.
How often should I optimize my WordPress database?
Monthly is enough for a quiet site; weekly suits an active blog, store, or membership site. On a schedule, each run is small and quick — clean only once a year and expect a bigger job.
Will cleaning the database delete my posts or pages?
No — the standard cleanup options you use to optimize WordPress database tables never touch published posts, pages, media, or their settings. Revisions, auto-drafts, trashed items, spam, and expired transients are safe to remove. Your backup is the safety net if anything unexpected happens.
What is the best plugin to optimize a WordPress database?
WP-Optimize is the best choice for most site owners: free, easy, and scheduled. Advanced Database Cleaner is better for detailed previews and orphan detection, and WP-Sweep is the best free option for developers who want WP-CLI control. Any of the three will optimize WordPress database tables properly.
Can I optimize my WordPress database without a plugin?
Yes — that is one way to optimize WordPress database tables without a plugin. In phpMyAdmin, select your database, tick all tables, and choose Optimize table to reclaim overhead space. You can also delete old revisions with the SQL query shown above. The manual route has no preview and no undo, so a backup is essential.
Why is my database still large after cleaning?
Usually because the bloat was not in the items you cleaned. Check for autoloaded options in wp_options, tables left behind by deleted plugins, and heavy postmeta from page builders. Advanced Database Cleaner’s table and options views show which are largest, so you can optimize WordPress database tables properly instead of cleaning the same small items again.
Conclusion
To optimize WordPress database tables safely: back up, find the bloat, clean the safe items with WP-Optimize or by hand in phpMyAdmin, then stop the growth with a revision limit and a monthly routine. The work takes about fifteen minutes the first time and five minutes a month after that — and the payoff is a faster admin area, faster pages, and smaller backups.
Do not chase the smallest possible database size — chase a healthy one. A few revisions and transients are normal; thousands are not. Keep the routine, watch the largest tables, and your database will stay lean for years. Facts checked 28 November 2026.