# Database Cleanup for WordPress

> Remove old revisions, auto-drafts, trash, spam, orphaned meta and expired transients, by hand or on a weekly schedule. Part of Toggleworks, one plugin for…

TW-PRF-04 Performance


Remove old revisions, auto-drafts, trash, spam, orphaned meta and expired transients, by hand or on a weekly schedule.

[Get it from $26 a year](https://togglework.app/pricing/#plans) [Try it in the demo](https://togglework.app/demo/)

Database Cleanup

**Part number**
: TW-PRF-04
**Section**
: [Performance](https://togglework.app/features/performance/)
**Settings**
: 3 (1 on/off)
**Starts**
: Switched off
**In plans**
: Every plan

## Why it matters

Over the years a WordPress database collects things nobody needs: hundreds of revisions per post, auto-drafts, trashed posts, spam comments, metadata left behind by deleted posts and expired transients. It makes backups bigger and some queries slower.

### What it does

- Removes revisions, auto-drafts, trash, spam and trashed comments.
- Removes orphaned post and comment metadata, and expired transients.
- Can keep items newer than a number of days.
- Runs by hand or on a weekly schedule.

![Database Cleanup settings screen in the Toggleworks WordPress plugin, showing Keep items newer than (days), Run a cleanup automatically every week, Include in the weekly cleanup](https://togglework.app/wp-content/themes/toggleworks-site/assets/img/parts/performance-db-cleanup.webp?v=1795524210)

The Database Cleanup screen in wp-admin, where you switch it on and change its settings.

## Set it up

1. Take a backup first ([Database Backups](https://togglework.app/features/core/backups/)).
2. Run a cleanup by hand and see what it removes.
3. Turn on the weekly cleanup with the items you are happy to remove automatically.

## What you can set

Switch Database Cleanup on in Toggleworks → Performance, then adjust any of these. Each one starts with a default, so you can switch the part on first and fine-tune later.

- Keep items newer than (days)
- Run a cleanup automatically every week
- Include in the weekly cleanup Post revisions · Auto-drafts · Trashed posts · Spam comments · Trashed comments · Orphaned post meta · Orphaned comment meta · Expired transients

## Good to know

- Revisions are your undo history. Keep recent ones (for example 30 days) if editors rely on them.
- To stop revisions piling up in future, limit how many WordPress keeps with [Revisions & Autosave](https://togglework.app/features/performance/revisions/).

[Guide: How to speed up a WordPress site, in the right order](https://togglework.app/guides/speed-up-wordpress/)

## One less plugin to install

Database Cleanup does a job people often install a separate plugin for:

- Database cleanup and Heartbeat controlOften done with WP Rocket

## Comes with 187 more parts

Database Cleanup is one part of Toggleworks, a single plugin for security, speed, SEO, backups, email and store tools. Switch on what your site needs; the rest stays off and loads nothing.

[All 18 Performance parts](https://togglework.app/features/performance/)

### People also look for it as

- database
- optimize
- revisions
- transients
- spam
- trash
- orphan
- postmeta
- cron
- clean

## Often switched on with it

- [Revisions & Autosave](https://togglework.app/features/performance/revisions/) — TW-PRF-16 · Limit how many post revisions are kept, and change the autosave and empty-trash intervals. · 4 settings
- [Unused Media Finder](https://togglework.app/features/performance/unused-media/) — TW-PRF-17 · Scan the media library for images and files that no post, page, product, widget or setting uses — then review and clean them up… · Own screen in wp-admin
- [AI Spam Filter](https://togglework.app/features/ai/spam-filter/) — TW-AI-19 · Catch the spam that gets past honeypots and captchas: AI reviews new comments and form entries and quietly files the junk — real… · 3 settings
- [CAPTCHA](https://togglework.app/features/security/captcha/) — TW-SEC-02 · Stop bots on the login, registration, lost password and comment forms with a simple math question or Cloudflare Turnstile. · 4 settings
- [Clean Admin](https://togglework.app/features/interface/clean-admin/) — TW-ADM-05 · Declutter wp-admin: hide the admin bar, notices, help tabs, update nags and admin bar items. · 7 settings
- [Cron Manager](https://togglework.app/features/core/cron-manager/) — TW-COR-07 · See every scheduled background task, when it runs next and whether it is overdue — run one now or delete leftovers from removed… · Own screen in wp-admin

## Questions

**Is Database Cleanup included in every Toggleworks plan?**

Yes. Every plan includes all 188 parts, Database Cleanup among them. Plans differ only in how many sites you can use them on, and staging or local copies of a site don’t count.

**Does Database Cleanup slow my site down when it’s switched off?**

No. Every part starts switched off, and a part that is off loads none of its code. Switch on Database Cleanup only if your site needs it.

**What if a setting locks me out?**

Add `define( 'TOGGLEWORKS_SAFE_MODE', true );` to wp-config.php. It pauses every part until you remove the line, and Tools → Recent changes lets you undo a change.

**Can I try Database Cleanup before I buy?**

Yes. The [live demo](https://togglework.app/demo/) runs a WordPress site with Toggleworks in your browser, and every plan has a 14-day refund.

## Switch off the plugin pile.

All 188 parts, one license, updates and support. 14-day refund.

[Choose a plan](https://togglework.app/pricing/#plans) [Try the live demo](https://togglework.app/demo/)

---

Source: https://togglework.app/features/performance/db-cleanup/
