Skip to content

Database Cleanup

Gaurav Tiwari edited this page Aug 27, 2026 · 1 revision

Database Cleanup

Scheduled removal of rows WordPress accumulates and never removes on its own. Off by default.

Tasks

Task Removes
revisions Post revisions beyond the retention count
auto_drafts Abandoned auto-drafts
spam_comments Comments marked spam
trashed_posts Posts in the trash
trashed_comments Comments in the trash
expired_transients Transients past their expiry
optimize_tables OPTIMIZE TABLE on the plugin's own and core tables

Each is individually switchable. Retain revisions defaults to 5 — the last five per post are kept.

Schedule

daily, weekly (default) or monthly. Changing it reschedules the event; disabling clears it.

Preview before you run

wp gt-performance database

reports what would be removed without removing it. Look at the counts before enabling anything on a site whose editorial history you care about — "revisions" can mean a lot of work on an established site.

Related settings

Two related controls live under Bloat, because they prevent accumulation rather than clean it up:

  • Limit revisions (default 5) caps revisions as they are created
  • Autosave interval (default 60s) reduces autosave churn

Capping revisions is generally better than deleting them later.

Related

Settings Reference · WP-CLI

Clone this wiki locally