Database Optimizer

Keep your WordPress database lean and fast by removing accumulated junk—revisions, spam, trashed posts, and expired transients—all with a single click.

Use Cases

  • Clean up 5,000+ post revisions and auto-drafts to shrink an oversized database from 2GB down to 500MB
  • Run database optimization before migrating to a new host to reduce export file size and transfer time
  • Defragment and optimize all tables on a long-running site to improve query performance
  • Clear out years of spam comments that slipped past your moderation queue

How It Works

  1. Open the Database Optimizer module settings in Switchboard
  2. Select which cleanup tasks you want to run (revisions, auto-drafts, trash, spam, transients, table optimization)
  3. Click “Optimize Database” and confirm the action
  4. The module runs each selected cleanup task and reports results

All operations happen server-side via AJAX, so you see progress feedback in real-time.

Settings

This module is a tool-only module—no automatic settings are saved. Each time you want to clean your database, you visit the settings panel and run the optimizer manually.

OptionDefaultWhat It Does
Delete Post RevisionsCheckedRemoves all stored revision history from posts and pages
Delete Auto-DraftsCheckedCleans up automatic drafts WordPress creates while you edit
Empty TrashCheckedPermanently deletes posts and pages sitting in Trash
Delete Spam CommentsCheckedRemoves all comments marked as spam
Delete Expired TransientsCheckedClears temporary cached data that has expired
Optimize Database TablesUncheckedRuns MySQL OPTIMIZE on all tables to defragment and reclaim space

Where to Find It

Location: Switchboard → Modules → Optimization → Database Optimizer

Click the “Optimize Database” button in the module settings. You’ll see a confirmation dialog before any data is deleted.

Understanding the Cleanup Tasks

Post Revisions

Every time you save a post, WordPress keeps a copy. After hundreds of edits across hundreds of posts, you might have tens of thousands of revisions. This option deletes all of them.

Auto-Drafts

WordPress automatically saves drafts as you type. These “auto-draft” posts pile up over time, especially if you frequently start posts without publishing them.

Trash

Posts, pages, and custom post types you’ve deleted stay in Trash for 30 days by default. This empties the trash immediately.

Spam Comments

If you moderate comments, spam can accumulate. This clears all comments marked as spam in one go.

Expired Transients

Transients are temporary cached values stored in the database. Plugins and themes use them frequently. Expired ones should auto-delete, but often don’t—this cleans them up.

Optimize Tables

Running MySQL’s OPTIMIZE TABLE command reclaims unused space and defragments data. This is especially useful after deleting large amounts of content.

FAQ

Is this safe to run on a live site?Yes, but with a caveat: these operations are permanent. Once you delete revisions or empty the trash, you can’t undo it. We recommend running a database backup before your first cleanup, just in case.
Will this break anything on my site?No. The cleanup only removes data that’s already marked as disposable (revisions, trash, spam, expired cache). Your actual published content, pages, users, and settings remain untouched.
How often should I run this?It depends on your site’s activity. High-traffic blogs with frequent edits might benefit from monthly cleanups. Smaller sites can run it quarterly or before major updates.
Why isn’t ‘Optimize Tables’ checked by default?Table optimization is a heavier operation that temporarily locks tables while running. On very large databases or shared hosting, this can cause brief slowdowns. Enable it when you have a maintenance window or low traffic.

Run Database Optimizer before creating a full backup—you’ll reduce backup file size and speed up the backup process.

All cleanup operations are permanent. There’s no undo. Always keep regular backups of your site.

PRO

Get access to all 147 modules with a single license

Upgrade to Pro