Database cleanup removes bounded categories of stale WordPress data and audits autoloaded options. It is designed to make the possible work visible before deletion.
Cleanup types
| Type | Typical target |
|---|---|
revisions | Old post revisions, with age/latest-count policy. |
auto_drafts | Abandoned editor auto-drafts. |
trashed_posts | Trashed posts past the selected retention. |
spam_comments | Spam comments and their metadata. |
trashed_comments | Trashed comments and their metadata. |
expired_transients | Expired transients and timeout rows. |
orphan_postmeta | Post meta without a parent post. |
unattached_media | Media not attached to content, subject to the current safety policy. |
oembed_cache | Expired oEmbed response cache entries. |
Preview, run, and schedule
wp wppo database counts
wp wppo database cleanup --type=all --dry-run
wp wppo database cleanup --type=expired_transients
wp wppo database cleanup --type=all --yesCleanup runs in bounded batches. The dashboard exposes the same canonical runner, counts, confirmation flow, and scheduling choices. A schedule of none, daily, weekly, or monthly is stored under the database-cleanup settings; a lock prevents overlapping runs.
Autoloaded-options audit
The audit lists the largest autoloaded options and can show a read-only parity comparison. Remediation supports a dry run, a bounded apply, a single-option revert, and revert-all. Review every candidate: an option that appears large may still be required on every request.
Activity and integrations
After aggregate or per-type work, the plugin writes an activity entry and fires wppo_database_cleanup_completed. Consumers should use safe result counts and avoid logging deleted content or credentials.
Verify
Run counts before and after, confirm the activity log, and purge page/derived caches when cleanup changes observable content or metadata. Test on staging with a database backup.