WordPress

WordPress database cleanup: remove old data without breaking a plugin

WordPress database cleanup is safest when every table and row class has an owner. Revisions, transients, sessions, plugin logs, Action Scheduler data, orphaned metadata, and deleted-plugin tables can grow, but “cleanup” tools can also remove data a plugin still needs.

Take a database backup and inventory tables

Record database size by table, row counts, storage engine, and the plugin/core feature associated with large tables. Export a recoverable database copy before destructive operations.

A table name prefix can hint at ownership but is not proof when plugins share core tables.

Understand each cleanup category

Expired transients are different from active options; post revisions may matter to editors; ecommerce sessions and scheduled-action history may have retention rules; logs may be operational evidence.

Use plugin/vendor documentation for purpose-built pruning when available.

Delete in bounded batches

Large deletes can lock tables, generate replication/binlog work, or cause I/O spikes. Batch cleanup and observe application/database latency. Avoid a massive delete during peak traffic.

Table optimization may require additional temporary disk space and should be planned separately.

Fix the retention source

After cleanup, configure log/session/action retention or remove abandoned plugins so growth does not immediately return. Monitor table size trend and query performance over time. Keep the before/after table-size report with the maintenance record so future operators can tell which growth is expected and which table changed unexpectedly.

  • Back up before deletion.
  • Map tables to owners.
  • Prune in controlled batches.
  • Add ongoing retention.
Related DotMoose serviceExplore DotMoose WordPress hosting

Keep reading

Related guides.

More wordpress →