What It Does
Database Optimizer scans your WordPress database for accumulated clutter: expired transients, excess post revisions, orphaned postmeta/commentmeta/usermeta, auto-drafts, trashed posts, stale cron events, and completed/failed Action Scheduler entries. It shows you exactly how much each category contains before you clean anything. Every cleanup operation creates a downloadable SQL backup file first, so you can restore deleted data by importing the backup.
Features
- Expired transient cleanup — removes transients whose timeout has passed, with option to clean all transients
- Post revision pruning — keeps a configurable number of most recent revisions per post (default: 5) and deletes older ones
- Revision preview — shows top "hoarder" posts with the most revisions before you clean
- Orphaned postmeta cleanup — finds and removes meta rows for posts that no longer exist
- Orphaned commentmeta cleanup — finds and removes meta rows for deleted comments
- Orphaned usermeta cleanup — finds and removes meta rows for deleted users
- Orphaned term_taxonomy cleanup — finds taxonomy entries without matching terms
- Orphaned term_relationships cleanup — finds relationship entries without valid taxonomy entries
- Auto-draft cleanup — removes auto-drafts older than 7 days
- Trashed post cleanup — removes trashed posts older than 30 days
- WP-Cron cleanup — identifies and removes orphaned cron hooks (hooks with no registered callbacks)
- Action Scheduler cleanup — cleans completed and failed Action Scheduler entries (WooCommerce)
- Table optimization — runs OPTIMIZE TABLE on WordPress tables to reclaim disk space (DATA_FREE)
- Table statistics — shows size and overhead for each WordPress table
- SQL backup before every cleanup — generates INSERT statements saved to wp-content/uploads/wpmultitool-backups/
- Secure backup downloads — files are served through WordPress admin-ajax.php with nonce verification
- Backup directory is protected with .htaccess deny from all
- DataStar SSE streaming for real-time progress during cleanup operations
How to Use
-
Open the dashboard
Go to WP Multitool > Database Optimizer. You will see cards for each cleanup category showing current counts, sizes, and health status (good/warning/critical).
-
Review the numbers
Each card shows how many items exist and their status. Red (critical) means significant cleanup is available. Check the revision "hoarder" list to see which posts have the most revisions.
-
Clean one category at a time
Click the cleanup button for each category. Each operation creates a SQL backup first, then performs the deletion. You get a download link for the backup file.
-
Run table optimization
After cleaning data, run "Optimize Tables" to reclaim the freed disk space. This runs MySQL OPTIMIZE TABLE on each WordPress table.
-
Download backups
Save the backup SQL files. If you need to restore deleted data, import the SQL file via phpMyAdmin or wp db import.
Settings
| Setting | Default | Description |
|---|---|---|
| Revisions to Keep | 5 |
Number of most recent revisions to keep per post when pruning. Minimum 1. |
| Auto-draft Age | 7 days |
Auto-drafts older than this are eligible for cleanup. |
| Trash Age | 30 days |
Trashed posts older than this are eligible for cleanup. |
FAQ
Will cleaning revisions break the "Undo" feature in the editor?
No. The editor undo/redo is in-session only and does not use revisions. Post revisions are separate snapshots. The module keeps your most recent revisions (default: 5 per post) and only removes older ones.
How safe is it to clean orphaned metadata?
Very safe. Orphaned postmeta/commentmeta/usermeta are rows that reference posts, comments, or users that no longer exist. They serve no purpose. A SQL backup is created before deletion, and you can restore it if needed.
Does "Optimize Tables" lock the database?
It depends on your MySQL storage engine. InnoDB (the default) performs online optimization without full locks, but it may cause brief slowdowns on very large tables. For most WordPress sites this completes in seconds. Run it during low-traffic periods on very large sites.
What are Action Scheduler entries?
Action Scheduler is a job queue used by WooCommerce and other plugins. Completed and failed entries pile up in the actionscheduler_actions table. Cleaning them is safe — they are historical records of past jobs, not pending work.
Where are backups stored?
In wp-content/uploads/wpmultitool-backups/. The directory is protected with an .htaccess file. Backup files are SQL containing INSERT statements. To restore, import the file via phpMyAdmin or run: wp db import filename.sql
Ready to optimize your WordPress site?
Join developers using WP Multitool to debug, optimize, and maintain WordPress.
Get WP Multitool