A WordPress database starts small and grows for years without anyone looking at it. By the time it becomes a problem — slow admin screens, backups that take too long, a host warning about storage — most of what is in there is not your content at all.
WordPress database optimization is unglamorous and it is one of the few maintenance jobs where you can see the result immediately.
What is actually filling it up
Four things account for nearly all of it, and none of them are pages or products. A WordPress database too large to back up quickly is almost always one of these rather than your content.
Post revisions. Every time you save a page, WordPress keeps the previous version. Edit a page forty times over three years and there are forty copies of it stored. On a site with a few hundred pages this is often the single largest table.
Expired transients. Plugins cache temporary data in the database with an expiry time. The expiry stops the data being used; it does not always delete the row. On a busy site these accumulate in thousands.
Spam and trashed comments. Trash is not deletion. Comments sit in it until something empties it, and on most sites nothing ever does.
Tables from plugins you removed. Deleting a plugin removes its files. It usually leaves its database tables exactly where they were, forever. A site five years old can be carrying tables for a dozen plugins nobody remembers installing.
What is safe to clean, and what is not
Before you clean a WordPress database, the distinction between these two groups matters more than the tool you use.
Safe: expired transients, spam comments, trashed posts and comments older than a month, and post revisions beyond the last few. None of this is content anyone will miss.
Safe with a look first: orphaned tables from removed plugins. Confirm the plugin is genuinely gone and not simply deactivated, and check the table name against the plugin you think it belongs to before removing anything.
Leave alone: anything you cannot identify. An unfamiliar table is not necessarily junk — it may belong to your theme, your form plugin or your store. The cost of deleting something needed is far higher than the benefit of a slightly smaller database.
Never on a live site without a backup. Database cleanup is one of the few maintenance jobs that cannot be undone by reinstalling something.
Limit revisions instead of deleting them repeatedly
Cleaning revisions once solves the problem for a month. Limiting them solves it permanently.
A single line in wp-config.php caps how many WordPress keeps per page — five is plenty for most sites, and it means the table stays a sensible size on its own rather than needing periodic attention. This is the better fix, and it is the one people skip because the cleanup tools do not mention it.
Autosaves work differently and are not affected by that limit. They are small and there is rarely a reason to touch them.
The part people get wrong: optimisation is not speed
It is worth being honest about what this does. A smaller database makes the admin area more responsive, makes backups faster and smaller, and makes a restore quicker when you need one. Those are real benefits.
What it usually does not do is make your pages load noticeably faster for visitors. Front-end speed is dominated by images, scripts, hosting and caching. A database cleanup on a slow site rarely changes what a visitor experiences, and anyone selling it as a speed fix is overselling it.
If pages are genuinely slow, our guide on how to speed up a WordPress website covers the things that actually move that number.
How often, and by whom
The tools that clean WordPress database tables all offer roughly the same options, so pick one and stick with it. Quarterly is plenty for most sites. Monthly if the site is busy or runs a store, where transients and session data accumulate faster.
The safe routine is always the same: take a backup, run the cleanup, then open the site and click through the pages that matter — the contact form, the checkout, a product page — to confirm nothing depended on what you just removed. Skipping that last step is how a cleanup becomes an incident.
It is a small job that never becomes urgent, which is exactly why it does not get done. Our website maintenance checklist puts it in the quarterly section, and scheduled maintenance work is the version where it happens without anybody having to remember.