---
title: Database Cleanup
description: "Clean up revisions, drafts, spam, transients and tables in WordPress with Powered Cache. Learn each task's risk, how to run it once and how to schedule it."
url: "https://poweredcache.com/docs/database-cleanup/"
updated: "2026-12-02"
category: Database
---

# Database Cleanup

Over time, the WordPress database collects data you no longer need: old post revisions, spam, items in the trash and leftover temporary data. Database Cleanup removes it in the background. A smaller database is easier to back up and can make some admin screens faster. It does not change what visitors see on cached pages.

**Available in:** Powered Cache (free). Scheduled cleanups need Powered Cache Premium.
**Where to find it:** Powered Cache → Database

**Make a backup first.** Most cleanup tasks delete data permanently, and there is no undo.

## How database cleanup works

You choose the cleanup tasks with the toggles in **Cleanup tasks**. Saving the toggles does not clean anything. A cleanup runs only when you start it with [Run Cleanup Now](#run-cleanup), or on a [schedule](#scheduled-cleanup) with Premium. Both use the same selection. The tasks run in the background with WordPress's Action Scheduler, so you can leave the page.

On a multisite network where Powered Cache is network activated, a cleanup runs on every site of the network.

## Cleanup tasks

All tasks are **off by default**.

| Task | What it removes | Risk |
| --- | --- | --- |
| [Post Revisions](#post-revisions) | All saved revisions of all posts and pages | Medium: you can no longer restore earlier versions. |
| [Auto Drafts](#auto-drafts) | Drafts WordPress creates automatically when you open the editor | Low |
| [Trashed Posts](#trashed-posts) | Everything in the trash | Medium: trashed items are deleted permanently. |
| [Spam Comments](#spam-comments) | Comments marked as spam | Low |
| [Trashed Comments](#trashed-comments) | Comments in the trash | Low |
| [Expired Transients](#expired-transients) | Temporary data that has already expired | Very low |
| [All Transients](#all-transients) | All temporary data, including data that is still valid | Medium: the site is slower until plugins rebuild it. |
| [Optimize Tables](#optimize-tables) | Unused space in non-InnoDB tables | Low, but tables can be locked while it runs. |

For most sites, a safe routine is Auto Drafts, Spam Comments, Trashed Comments and Expired Transients. Add Post Revisions only if you do not rely on revisions.

### Post Revisions

Deletes every saved revision of every post, page and custom post type entry. The current version of each post stays. Powered Cache does not keep the latest few revisions, so after the cleanup the *Revisions* panel in the editor is empty. If you rely on revisions to restore content, do not schedule this task.

### Auto Drafts

Removes the empty drafts WordPress creates when you open the editor for a new post. Your own drafts are not affected. Auto drafts of posts and pages are moved to the trash, because WordPress handles them that way while the trash is enabled. Auto drafts of other post types are deleted right away. Combine this task with [Trashed Posts](#trashed-posts) to remove them completely.

### Trashed Posts

Permanently deletes every post, page and custom post type entry in the trash, without waiting for WordPress to empty the trash after 30 days. Look through the trash before you run it.

### Spam Comments

Permanently deletes all comments marked as spam.

### Trashed Comments

Permanently deletes comments in the trash, including comments that were trashed together with their post. If you later restore such a post from the trash, its comments do not come back.

### Expired Transients

Transients are temporary data that plugins and themes store with an expiry time. This task deletes the ones that have already expired from the database, also when a persistent [object cache](/docs/object-caching/) is active. It is the safest task and a good candidate for a schedule.

### All Transients

Deletes **every** transient, including those that are still valid and network-wide (site) transients. Plugins rebuild what they need, but until then pages that use that data are slower, and plugins may call their external services again, for example to check for updates or refresh API data. Use it once to fix a bloated options table, not as a regular task. If you select it, you do not also need Expired Transients.

### Optimize Tables

Runs `OPTIMIZE TABLE` to reclaim unused space. It only touches tables that use your WordPress table prefix, do **not** use the InnoDB storage engine (for example MyISAM tables), and have unused space. InnoDB tables, the default on modern MySQL and MariaDB, are skipped, so on many sites this task does nothing. Tables can be locked while they are optimized, so run it at a quiet time. On a multisite network, the tables are optimized once for the whole network.

> **Changed in 4.0:** Optimize Tables works on MySQL 8 and is limited to WordPress tables. Tables of other applications in the same database are left alone.

## Run a cleanup once

1. Make a backup of your database.
2. Go to **Powered Cache → Database**.
3. Turn on the cleanup tasks you want.
4. In the **Run Database Cleanup** panel at the bottom, click **Save & Run Cleanup**. If you have no unsaved changes, the button says **Run Cleanup Now**.
5. The notice *Database cleanup has started in the background.* confirms the start.

The button is disabled until at least one task is selected. Large sites can need several minutes. Background jobs rely on the WordPress scheduler, so if `DISABLE_WP_CRON` is set in `wp-config.php`, make sure a server cron job calls `wp-cron.php`.

> **Changed in 4.0:** in 4.0, a manual cleanup was started from the *Optimize Database* card in Powered Cache → Tools. Since 4.0.1, the *Run Database Cleanup* panel in the Database section starts it, and saves your task selection first.

## Scheduled cleanups (Premium)

With Powered Cache Premium, the selected tasks can run automatically.

### Scheduled Cleanups

Runs the selected cleanup tasks on a schedule. **Default: off.** The first run starts shortly after you save, and later runs follow the chosen frequency. Turning it off also cancels a cleanup that is waiting to run.

### Database Cleanup Frequency

How often scheduled cleanups run. **Default: Daily.** Changing the frequency starts the new schedule with a run shortly after you save.

| Option | Behavior in 4.1 |
| --- | --- |
| **Daily** | Once a day. |
| **Weekly** | Once a week. A good choice for most sites. |
| **Hourly**, **Twicedaily** | Run once a day, like Daily. |
| **Monthly** | No cleanup is scheduled, because WordPress has no monthly schedule unless another plugin adds one. Choose Weekly instead. |

Only schedule tasks you would be comfortable running without checking first. Expired Transients, Spam Comments and Auto Drafts are good candidates. Avoid All Transients on a schedule.

## Troubleshooting

### The cleanup does not seem to run

- Check that at least one task is turned on and saved. Scheduled cleanups run the saved selection.
- Check **Tools → Scheduled Actions** in WordPress for pending `powered_cache_db_optimizer` actions in the `powered-cache` group. If they stay pending, WP-Cron is not running.
- Turn on the [debug log](/docs/debug-log/). Each task writes a line such as `Optimizing...db_cleanup_post_revisions`, and the end of a run writes `Optimization completed...`.

## Related docs

- [Object Caching](/docs/object-caching/)
- [Multisite Setup](/docs/multisite-setup/)
- [Free vs Premium](/docs/free-vs-premium/)
- [Debug Log](/docs/debug-log/)
