WordPress database cleanup that backs up first
Optimize shows what each website's database carries that nothing reads, from old revisions to data left behind by deleted pages, and clears the kinds you tick once a backup has finished. It also finds the images and files no page, page builder or setting uses, and moves the ones you choose into a bin you can undo for 30 days.
Included on every paid plan, from Solo up.
Updated

What is WordPress database cleanup?
WordPress database cleanup means deleting the rows a site keeps but never reads again: old post revisions, data left behind by deleted pages and comments, unfinished automatic drafts, spam and binned comments, and expired transients. In WPCentrify it is the Optimize tab on each website. It counts every kind first, shows the rows and size of each, and deletes only the kinds you tick, after a backup of the database has finished.
It builds up because WordPress keeps things on purpose and rarely lets go. By default it keeps every revision of every page, page builders save their layout data with each revision, and deleting a page or a comment can leave its data rows behind. None of it shows on the website, but every backup copies it and every restore writes it back.
Page builders are usually why the first count is large. They save a copy of a page's layout with every revision, and a cleanup plugin that deletes revisions without their data leaves those copies behind, where every backup still reads them. Optimize counts that leftover data as a line of its own, so you see it before you decide.
The same tab answers the media question too: which uploads does nothing on the website use? They are listed by size, and the ones you choose go into a bin on the website instead of being deleted.
Optimize at a glance
- Counts 8 kinds of database clutter, with rows and size for each, and changes nothing while it counts
- Keeps the newest 5 revisions of every page, plus its autosave
- Backs up the database before every cleanup, and deletes nothing if that backup does not finish
- Lists unused images, PDFs, videos and other uploads, never ones from the last 30 days
- Moves unused media into a bin: put back with one click, deleted for good after 30 days
- Included on every paid plan, from Solo up, one website at a time
What does Optimize clear from a WordPress database?
Eight kinds of rows, each something WordPress never reads again. Nothing a visitor or an editor sees changes when they go.
| What | What it is | Always kept |
|---|---|---|
| Data of deleted pages | Settings and page-builder data in the postmeta table, left behind when a page or a revision was deleted. Often called orphaned postmeta. | The data of every page and revision that still exists |
| Old page revisions | Earlier saved versions of each page and post. | The newest 5 revisions of every page, and its autosave |
| Unfinished automatic drafts | Drafts WordPress starts every time somebody opens the editor. | Any started in the last 7 days |
| Spam comments | Comments marked as spam. | A spam comment with a reply under it |
| Comments in the bin | Comments somebody moved to the bin. | Approved comments and comments waiting for approval |
| Data of deleted comments | Comment meta left behind when a comment was deleted. | The data of every comment that still exists |
| Data of deleted categories and tags | Term meta left behind when a category or tag was deleted. | The data of every category and tag that still exists |
| Expired transients | Values plugins stored for a set time, whose time has passed. A plugin that needs one makes it again. | Transients that have not expired yet |
You choose the kinds. Every kind with something in it starts ticked, and you can untick any of them before you clean up.
Is it safe to clean up a WordPress database?
It is when three things are true, and Optimize makes sure of each before it deletes a single row.
- A backup comes first, every time. Back up, then clean up starts with a backup of the database. If that backup fails, is cancelled or does not finish, nothing is deleted.
- Every row is checked again as it goes. The numbers on screen come from the last count. At the moment it deletes, the website works out again what qualifies, so a page restored or a comment answered since the count is left alone.
- Nothing else runs into it. One cleanup at a time on a website, never while an update is running, and the work goes in small batches inside a time limit, so no single request runs long on a shared host.
It deletes with plain database queries rather than WordPress's own delete functions, on purpose: those would run every plugin's clean-up code and write an activity line for each of hundreds of revisions. The activity log records who started the cleanup and what it cleared.
Need something back? The backup is on the website's Backups tab, and restoring it puts the whole database back to the moment before the cleanup.

How to clean up a WordPress database with WPCentrify
Four steps, and the first two change nothing on the website.
Open Optimize on the website
Choose the website in WPCentrify, then Optimize. The first time, it counts on its own. Counting reads the database and changes nothing.
Read the count
Each kind of clutter shows its rows and its size, beside the size of the whole database and how much of it nothing on the website reads.
Tick what to clear
Every kind with something in it starts ticked. Untick any kind you would rather keep for now.
Back up, then clean up
Confirm, and WPCentrify backs up the database, then clears the kinds you ticked. You can leave the page. When it finishes, it counts again and shows what was cleared.
How do you find unused media in WordPress?
The media library cannot tell you, because WordPress does not record where an image is used. A page can show an image by its file name, or by its ID inside a block, a shortcode, a page builder's settings, a widget or a theme option. Optimize reads all of those before it calls a file unused:
- Every page and post, including the data page builders such as Elementor, Bricks and Oxygen save
- Widgets, theme and plugin settings, and every plugin's own tables, apart from logs and file lists
- The active theme's own files, such as its stylesheets
- Every copy of a file: resized sizes, scaled versions and WebP copies
When in doubt, a file counts as used. A number that only happens to match an image's ID keeps that image. If part of the website cannot be read, the count stops and says so instead of listing files that may be in use. Uploads from the last 30 days are never listed, because somebody may be about to use them.

What happens to the media you remove?
Nothing is deleted when you press the button. Every file of the upload, its resized copies included, moves into a bin folder on the website that visitors cannot reach, and the upload leaves the media library. Its record is kept, so it can come back exactly as it was.
- Put any file back with one click for 30 days
- After 30 days the website deletes it for good, on the date shown beside it
- Featured images, the website's icon and its logo are checked again as they go, and stay where they are
- A list more than a day old must be counted again first, in case something started using a file

Can you restore deleted media in WordPress?
Not once WordPress has deleted it: the files are gone from the server and only a backup brings them back. That is why Optimize moves media to a bin instead. Choose a file under In the bin and press Put back, and the files return to their folders and the upload reappears in the media library.
If a new upload has taken the same file name since, putting it back is refused rather than replacing the newer file.

Does cleaning the database make WordPress faster?
Sometimes a little, and it is better to be honest about it. What a cleanup reliably shrinks is everything that copies the database: backups are smaller and quicker, a restore or a move to a new host has less to write, and admin screens that list revisions and comments have less to read.
How fast pages load for visitors depends far more on caching, hosting and what each page asks of the database. Leftover rows can slow some queries, but nobody can promise faster pages from a cleanup alone. To see real changes, track each site's Core Web Vitals with performance monitoring, and for the fixes that move them, read how to improve Core Web Vitals on WordPress.
Optimize or a cleanup plugin on every site?
Most WordPress cleanup runs as a plugin installed on each website. Here is how the common choices compare, from each vendor's own pages, checked 19 October 2026.
| Tool | What it cleans | How it runs | Price |
|---|---|---|---|
| WPCentrify Optimize | Database clutter (8 kinds) and unused media, with a 30-day bin | From the WPCentrify dashboard, one website at a time. A database backup is always taken first. | Every paid plan, from Solo up |
| WP-Optimize | Database cleanup. Unused images in Premium. | Plugin on each site. Scheduled cleanups, and a backup with UpdraftPlus before cleaning if you add it. | Free. Premium from $49 a year for 2 sites |
| Advanced Database Cleaner | Database only | Plugin on each site | Free. Premium from $39 a year for 1 site |
| Media Cleaner | Unused media only. Page builders in Pro. | Plugin on each site, with a trash before anything is deleted for good | Free. Pro from $39 a year for 1 site |
| MainWP Maintenance | Revisions, drafts, trash, comments, transients and table optimization. No media. | Self-hosted MainWP dashboard, with schedules | Part of MainWP Pro, $199 a year |
| WP Umbrella | Database cleanup (transients, spam, comments). No media listed. | From the WP Umbrella dashboard, in bulk | $2.19 per site a month |
Sources: WP-Optimize, WP-Optimize pricing, Advanced Database Cleaner, Media Cleaner, Media Cleaner Pro, MainWP Maintenance, MainWP pricing, WP Umbrella pricing. If you need cleanups on a schedule, or across many sites in one run, MainWP and WP Umbrella do that today. Optimize works one website at a time.
What Optimize does not do
It clears clutter. It is not a tuning tool, and it is better to know that before you rely on it.
- It does not run OPTIMIZE TABLE or rebuild tables
- It does not change autoloaded options or remove tables left behind by plugins you deleted
- It does not compress images or remove the extra sizes of images that are in use
- It does not swap a file for a new version. To replace an image on every page that uses it, use Media replacement
- It does not run on a schedule or across several websites at once. You run it per website, when the count says it is worth it
- It cannot see a file used only by an inactive theme, written into a plugin's code, or linked from another website or an email. That is what the bin is for
- A website served over http cannot be backed up, so its database cleanup waits until it moves to https. The media bin still works
- It needs the WPCentrify plugin at version 1.0.33 or newer, and the tab says so when a website needs an update
Questions about WordPress database cleanup
What people ask before they clear a database or a media library.
Yes, when a backup comes first and only rows nothing reads are removed. WPCentrify backs up the database before every cleanup and deletes nothing if that backup does not finish. It deletes only the kinds you tick, and checks each row again at the moment it deletes it.
Always, because WordPress cannot undo a database cleanup by itself. WPCentrify takes the backup for you: pressing Back up, then clean up backs up the database first, and the backup stays on the website's Backups tab in case you ever need to restore it.
WordPress keeps every revision unless the WP_POST_REVISIONS setting limits it. A handful per page is enough for most sites. WPCentrify keeps the newest 5 revisions of every page, plus its autosave, and clears the older ones.
Transients are values plugins store for a set time, such as a cached feed or a reply from another service. Once that time has passed, nothing reads them. Deleting expired ones is safe: a plugin that needs a value again simply makes it again.
Orphaned postmeta is data in the postmeta table that belongs to a page, post or revision that no longer exists. Page builders store a lot of data there, so it can be one of the largest kinds of clutter. WPCentrify lists it as data of deleted pages, with its size.
It makes backups, restores and moves to a new host smaller and quicker, and can help admin screens that read revisions and comments. How fast pages load for visitors depends much more on caching and hosting, so a cleanup alone is no promise of faster pages.
It reads every page and post, page-builder data, widgets, settings, every plugin's own tables and the active theme's files, looking for the file name in any size and for the image's ID. A file is listed only if nothing names it, and uploads from the last 30 days are never listed.
Yes, for 30 days. Removed files go into a bin on the website instead of being deleted. Choose a file under In the bin and press Put back, and it returns to the media library. After 30 days the website deletes it for good.
When the count shows something worth clearing. On a busy site that may be every month or two, and on a quiet one a few times a year. A cleanup before a big backup or a move to a new host is always worth it. Counting changes nothing, so you can check whenever you like.
Yes. You can run SQL in phpMyAdmin or use WP-CLI, but one wrong query can break a site, so take a backup first. With WPCentrify there is no extra plugin to install: Optimize works through the WPCentrify plugin the website already runs, and takes the backup for you.
Every paid plan, from Solo up. It needs the WPCentrify plugin at version 1.0.33 or newer. The Free plan covers uptime monitoring only.
Related features
Backups and restore
Encrypted off-site backups for every site, and the restore point every cleanup starts with.
Read moreRestore and recovery
Put a website, or just its database, back from a restore point when something goes wrong.
Read morePerformance monitoring
Core Web Vitals and PageSpeed for every site, so you can see what actually changed.
Read moreMore on this topic: how to make a WordPress backup, the WordPress maintenance guide and the WordPress maintenance checklist.
See what each database is carrying
Connect a site and open Optimize. The first count shows every kind of clutter with its size, and nothing changes until you choose.
Plan prices to be revealed. Keep your data, export any time.