Blog/WordPress
WordPress · Database

WordPress Database Bloat: What It Is, Why It Happens, and How to Fix It

Naveen Goyal
16 June 2026
5 min read
WordPress · Performance

A fresh WordPress database is a few megabytes. After two years of active use — posts, revisions, plugin data, WooCommerce orders — it's common to see databases of 500MB to several gigabytes on sites that don't do any maintenance. Most of that is waste.

Database size affects query speed. A bloated wp_postmeta table with millions of orphaned rows means every metadata lookup takes longer. On shared hosting where MySQL resources are capped, this becomes a measurable performance problem.

What Actually Accumulates

  • Post revisions — WordPress saves a revision every time you save a draft or update a post. By default, there's no limit. A post edited 50 times has 50 revisions stored in wp_posts and their associated metadata in wp_postmeta. On a content-heavy site, revisions can account for half the database size.
  • Transients — Plugins store cached data as transients in wp_options. Expired transients are supposed to be cleaned up automatically, but when object caching is enabled or cleanup fails, they accumulate. Thousands of expired transients in wp_options slows the options load on every page request.
  • Orphaned postmeta — When a post is deleted, its rows in wp_postmeta should be deleted too. Many plugins skip this cleanup. A site that has created and deleted thousands of posts can have hundreds of thousands of orphaned postmeta rows referencing post IDs that no longer exist.
  • WooCommerce order data — Order items, order meta, and session data accumulate rapidly on active stores. WooCommerce sessions in wp_woocommerce_sessions can grow to millions of rows without regular cleanup.
  • Auto-drafts and trashed posts — WordPress creates an auto-draft on every new post screen visit. Deleted posts sit in the Trash until manually emptied. Both accumulate silently.
  • Plugin-specific tables — Plugins like contact form plugins, analytics plugins, and security plugins create their own tables and fill them with log data that's rarely purged.
Before cleaning: always backup

Database cleanup deletes data permanently. Always take a full database backup before running any cleanup operation — even with tools that claim to be safe. A transient that looks expired might be actively used by a plugin in an unexpected way. Backup first, clean second, verify the site still works after.

How to Clean It Safely

The fastest manual approach: add define('WP_POST_REVISIONS', 5); to wp-config.php to limit future revisions to 5 per post. This doesn't clean up existing revisions but prevents the accumulation from getting worse.

For existing bloat, WP-CLI (if your host supports it) is the most reliable tool:

  • wp post delete $(wp post list --post_type=revision --format=ids) — delete all revisions
  • wp transient delete --expired — delete expired transients
  • wp db optimize — reclaim space after deletions via OPTIMIZE TABLE

Plugins like WP-Optimize can do this via a UI and can schedule automatic cleanup. The risk with any automated cleanup is deleting something a plugin is using — which is why a log of what was deleted is important.

The Database Monitor being built at MAA Labs will track database size over time, surface which tables are growing fastest, identify orphaned data, and run safe scheduled cleanup. Free when it launches.

Database Monitor is live on WP.org.

Health scoring, table inspector, one-click cleanup and scheduled maintenance — v1.0.1, 100% free on WordPress.org.

Install free →