WordPress writes to its database constantly, for every post revision, every plugin setting, every scheduled task. Most site owners never look at what’s actually accumulating in there until the site starts feeling sluggish, and by then, the database has usually been quietly bloating for months or years.
Here’s what actually causes it, and how to clean it up without breaking anything.
What actually bloats a WordPress database
Post revisions. WordPress saves a full revision every time you save a draft or update a published post, by default with no limit. A page edited fifty times over the years can be carrying fifty extra rows in the database for a single piece of content.
Spam and trashed comments. These sit in the database indefinitely unless manually cleared, taking up space and slowing down any query that touches the comments table.
Expired transients. Transients are temporary cached data plugins use to speed things up, but many plugins fail to clean up expired transients properly, leaving old cache data sitting in the database long after it’s useful.
Orphaned metadata. When plugins get deactivated or deleted, they don’t always clean up after themselves. Their settings and metadata can remain in the database indefinitely, referencing a plugin that no longer exists.
Unused tables. Old plugins and themes sometimes leave entire tables behind after removal, quietly taking up space with no active purpose.
How to clean it up
- Limit post revisions going forward. Add a line to your
wp-config.phpfile to cap the number of revisions WordPress keeps per post, rather than storing an unlimited history. - Clear spam and trashed comments through the Comments panel, or automate it with a cleanup plugin so it doesn’t reaccumulate.
- Delete expired transients. A cleanup plugin like WP-Optimize or Advanced Database Cleaner can identify and remove these safely without touching active data.
- Audit orphaned metadata left behind by deactivated plugins, ideally before deleting the plugin, but a cleanup tool can catch what’s already been left behind.
- Back up before any cleanup. Database cleanup is generally safe, but it’s still a direct edit to your site’s data. A backup first means a mistake costs you nothing.
What not to touch
Don’t run aggressive “optimize all tables” operations blindly on a live production database without a backup, and don’t delete anything from the database directly through phpMyAdmin unless you’re certain what a table or row actually does. Some plugins store legitimate, actively-used data in ways that look like clutter to an untrained eye.
Free plugins like WP-Optimize handle most of this safely, with clear before-and-after size comparisons. Paid tiers add scheduled automatic cleanup, worth it for sites you’re not actively managing day to day, not necessary for a one-time cleanup.
Why this actually matters for speed
Every page load queries the database. A bloated database means every one of those queries has more to sift through, even for data that has nothing to do with the page being loaded. Cleaning it up doesn’t just reduce disk space, it reduces the query load contributing directly to your site’s TTFB.