Database cleanup can reduce clutter and make administration easier, but bigger is not automatically slower, and deleting unfamiliar tables is risky. Start with evidence: identify what consumes space, what is loaded on every request, and which data no longer serves a purpose.
Back up and inspect first
Create a complete database backup and verify that it can be restored to a separate environment. Record table sizes, row counts, and the largest option values. Note active plugins, recently removed plugins, multisite status, and any custom integrations before changing data.
Low-risk cleanup candidates
- Expired temporary cache entries that WordPress no longer needs.
- Old post revisions beyond the editorial retention policy.
- Spam or trashed comments after the review period.
- Orphaned metadata confirmed to have no parent object.
- Completed background-job logs past their troubleshooting window.
Even common cleanup targets can matter to an audit or recovery process. Set retention based on business needs rather than using the most aggressive setting.
Pay attention to autoloaded options
Some options are loaded during many WordPress requests. A small number of oversized autoloaded records can be more important than a large archive table used only in the dashboard. Identify the owning plugin before changing the autoload flag or deleting an option.
Do not drop tables by name alone
Inactive or deleted plugins may leave tables intentionally so settings and submissions survive reinstallation. Search plugin documentation, inspect table prefixes and schemas, and confirm that no custom code still queries the data. Export uncertain tables separately before removal.
Use staging and small batches
Run the cleanup on a fresh staging copy, then test pages, search, forms, orders, accounts, scheduled tasks, and reports. In production, work in small batches during a quiet period and monitor database load. Large deletions can lock tables or create a long-running operation.
Prevent clutter from returning
Adjust revision limits, log retention, session cleanup, analytics storage, and queue schedules at their source. Avoid running multiple optimization plugins with overlapping jobs. Document every manual deletion and the reason behind it.
Safe database maintenance is conservative. The goal is a known, supportable data set—not the smallest number on a dashboard.