Optimise your WordPress database
Clear out post revisions, auto-drafts, spam and transients with the LiteSpeed Database Optimizer, and know which options are safe to run.
WordPress databases accumulate data that is never read again — old post revisions, abandoned drafts, expired transients, deleted comments. Clearing it reduces database size and speeds up queries. Applies to all shared and reseller hosting, which runs LiteSpeed.
The Database Optimizer is part of the LiteSpeed Cache plugin, so if the plugin is installed you already have it. See Install and enable LiteSpeed Cache.
Take a backup first. Every option here deletes data permanently, and there is no undo. See Download a backup of your account.
Open it
In the WordPress dashboard, go to LiteSpeed Cache → Manage, then the DB Optimizer tab.
Blue check marks mean an area is already clean. Red crosses mean there is something to remove.
What each option removes
| Option | Removes | Safe to run |
|---|---|---|
| Post Revisions | Every saved revision, leaving the published version | Yes, if you do not need edit history |
| Auto Drafts | Automatic drafts WordPress saves while editing | Yes |
| Trashed Posts | Posts and pages in the Trash | Yes, once you have checked the Trash |
| Trashed Comments | Comments in the Trash | Yes |
| Spam Comments | Comments marked as spam | Yes |
| Trackbacks & Pingbacks | Trackback and pingback records | Yes |
| Expired Transients | Cached values whose lifetime has passed | Yes |
| All Transients | Every transient, expired or not | Yes, but see below |
| Optimize Tables | Nothing — reclaims space inside the tables | Yes |
| Clean CSS/JS Optimizer | Minified and combined CSS/JS data | Yes |
Clean All runs everything except Optimize Tables and Clean CSS/JS Optimizer. Run those two separately.
The two worth thinking about
Post Revisions is usually the largest single saving. WordPress keeps every revision of every post forever, so a heavily edited site can hold ten times more revision rows than published content. The cost is that you lose the ability to roll a post back to an earlier draft.
To keep some history rather than none, cap revisions in wp-config.php instead
of deleting them repeatedly:
define( 'WP_POST_REVISIONS', 5 );All Transients deletes cached values that have not yet expired. Nothing breaks — WordPress regenerates them on demand — but the next few page loads are slower while it does, and some plugins store licence checks and API responses as transients. Prefer Expired Transients for routine cleaning.
Do this periodically, not constantly
Once a month is ample for most sites. Running it daily produces no measurable benefit and repeatedly rewrites the tables.
If the database is still large after cleaning, the size is in real content or in plugin tables the optimiser does not touch — commonly logging, analytics or form-submission plugins storing rows indefinitely. Check those plugins' own retention settings.
Verify
- The DB Optimizer tab shows blue check marks where it showed red crosses.
- The site loads normally, including a logged-out page and the dashboard.
- Database size in cPanel has dropped, after running Optimize Tables — until then the rows are deleted but the space is not reclaimed.
Related
Stop LiteSpeed cutting off long-running PHP scripts
Use the noabort and noconntimeout environment variables in .htaccess so backups, imports and WP-Cron finish instead of being killed part-way.
Enable WP_DEBUG and read the error log
Turn on WordPress debug logging to find the source of a white screen or a broken plugin, without showing errors to your visitors.