The WordPress database gets fat. What to clear out and what to leave
Revisions, transients, spam and the leftovers of plugins you deleted years ago. Which ones are safe to bin, which ones to leave alone, and the one rule before you start.
A clean-up plugin tells you it has found 14,000 items it can remove, with a big button to do it. Or your host emails to say the database has grown past its allowance. Either way you are looking at something called the database for the first time, and you have no idea which of those 14,000 things your website needs.
Most of it is junk. Some of it is your customers’ orders. The trick is knowing which is which before anybody presses the button.
What the database holds
A WordPress site keeps its files in one place and its content in another. The files are the theme, the plugins and the images. The database holds the words: every page and post, every setting, every user account, every form entry and every order if you sell online.
WordPress and its plugins write to the database all day and clear up after themselves badly. A site that has been running for five years with a dozen plugins coming and going will have collected a good deal that nothing reads any more. That costs you disk space, slower backups, and on a busy site a slower page, because the server has more to wade through to find what it needs.
Old revisions of your pages
Each time you click Update on a page, WordPress keeps the old version as a revision. It is a useful safety net: you can roll a page back to how it looked last Tuesday. It is also how a site with forty pages ends up storing two thousand copies of them, because nobody has ever told it to stop.
Safe to remove, apart from the last few of each page. Keep three or four recent ones so you can still undo a bad edit. Your developer, or whoever looks after the site, can also put a cap on how many WordPress keeps in future with one line in wp-config.php, so the pile does not grow back.
Spam and binned comments
If your site has comments switched on, the spam filter catches the rubbish and keeps it in a spam folder. Comments you deleted sit in the bin. On a site that has had comments open for years, those two folders can hold more than the rest of the site put together.
Safe to remove. Nothing on the site reads them. If you have never wanted comments at all, switch them off in Settings, Discussion, and the problem stops at source.
Transients
A transient is a note a plugin leaves itself: the weather forecast it fetched an hour ago, a count of your Instagram followers, the result of a slow calculation it does not want to repeat. Each one carries an expiry time. WordPress is supposed to clear the expired ones, and on plenty of sites it falls behind.
Expired ones are safe to remove. A plugin that needs one will make it again the next time a visitor arrives. Clearing the live ones is harmless too, but the next few page loads will be slower while they rebuild, so do it at a quiet time.
Leftovers from plugins you deleted
This is where the real weight tends to be, and where the risk is. When you delete a plugin, WordPress removes its files. A lot of plugins leave their settings and their data tables behind, in case you reinstall. A security plugin you tried for a month in 2021 may still have a table of every visit it logged, sitting there long after the plugin went.
Some of that data is loaded on every page. WordPress keeps a table of settings, and anything marked to load automatically gets read in full each time somebody views the site, whether the plugin that wrote it still exists or not. A few hundred stale rows there will slow every page by a small amount, all day.
Safe to remove once you know what it is. Table names do not always say which plugin made them, and a name that looks like an old plugin can belong to one you still use. If nobody can say what a table is for, leave it.
What to leave alone
Some things look like clutter and are not:
- Form entries and orders. Contact form submissions, WooCommerce orders and booking records can run to tens of thousands of rows. They are records, and in the case of orders you may be obliged to keep them for your accounts. A clean-up plugin will sometimes offer to delete old ones. Say no unless you have exported them first and know you can.
- Anything you cannot name. Users you do not recognise belong in an admin user audit, not a clean-up. A table you cannot place belongs to whoever can tell you what it does. A guess that deletes the wrong table takes part of the site with it, and there is no undo.
The rule before you touch any of it
Take a backup of the database first. Then check it is a real one: stored off the server, with today’s date on it, and a file size that looks right for a site of your size. Our piece on what a backup should do has a five-minute check for that.
Better still, do the clean-up on a copy of the site and look round it before doing the same to the live one. Click through the pages, submit the contact form, log in, and on a shop put a test order through. If all of that works on the copy, you can do the live site with some confidence.
Clean-up plugins are fine for the first three jobs here. Untick everything to do with orders, entries and tables, run the safe parts, then remove the plugin itself. One more plugin left running is one more thing to keep updated.
How much difference it makes
Less than the plugin’s big number suggests. Clearing revisions and spam makes backups smaller and quicker, which matters, but most visitors will not notice the change. The leftovers that load on every page are the ones that make a site faster, and on a site that has been through a lot of plugins that can be a noticeable gain.
If your site has slowed down and you are hoping a clean-up will fix it, check the other causes in why a WordPress site suddenly slows down first. A full database is one suspect of five, and rarely the one with the date on it.
Once or twice a year is plenty for most small business sites. It is the kind of job that gets forgotten for five years and then done in a hurry, which is when the wrong table goes. Our website care and hosting plan does it as part of the monthly maintenance, with a tested backup taken first, for £49 a month. If you would like to know how much of your database is worth clearing before you decide, the free website review will tell you.



