A client says their WordPress site has been getting a little slower. Not broken, nothing dramatic, just a steady slide with every month that passes. Nothing new was added, and the hosting hasn’t changed. So what has?
Very often, when a WordPress site is slower than it used to be, the answer is in the database. WordPress stores its settings and temporary data in one table, wp_options, and its edit history as revisions. None of it looks like much on its own, but a site that’s been running for a few years collects a quiet pile of leftovers.
I see three kinds of leftovers more than any others: post revisions, old transients, and autoloaded options left behind by plugins that were deleted long ago. Here’s what each one is, and the tidy-up I do.
Revisions: every save keeps a copy
Every time you update a post or a page, WordPress saves a copy of the previous version so you can roll back. That’s useful, and I’m not saying switch it off. But by default there’s no limit. A page that’s been edited every week for five years can have hundreds of revisions sitting behind it.
On a busy blog or a shop with lots of product copy, the revisions can end up outnumbering the pages themselves. Each one is another row the database has to store and search through.
The fix is to keep some revisions, not all of them. One line in wp-config.php caps how many WordPress keeps for each post or page:
define( 'WP_POST_REVISIONS', 5 );
I’d keep at least a few, because being able to undo last week’s edit is worth more than the space it takes. The cap only trims old revisions the next time that post is saved, so it doesn’t clear the backlog on its own. If you use WP-CLI, you can count them first with wp post list --post_type=revision --format=count.
Transients: temporary data that doesn’t always go away
A transient is a piece of data WordPress or a plugin saves for a set time, so it doesn’t have to work it out again. Licence checks, update information and the results of slow queries are common examples. Each one gets an expiry time.
WordPress runs a daily clean-up of expired transients. That doesn’t always catch everything. WP-Cron only runs when someone visits the site, some plugins create a new transient with a unique name every time they run, and transients with no expiry time never run out at all. Over a few years, those leftovers add up.
Each one is small, but thousands of them make the options table bigger than it needs to be, and the ones without an expiry time are autoloaded on every page.
With WP-CLI, wp transient delete --expired clears out the expired ones. It leaves the ones that are still in date alone, which is what you want. Don’t use --all unless you know what you’re doing, because that clears live transients too and the site has to rebuild them. If your host uses an object cache such as Redis or Memcached, transients are usually kept there instead of the database, so finding none is normal.
Autoloaded options: the leftovers plugins leave behind
This is the one that surprises people most. WordPress keeps its settings in the options table, and some of those settings are marked to be “autoloaded”. That means WordPress fetches them all in one go on every single page load, for visitors and in wp-admin.
That’s fine when the list is small. But many plugins save their settings as autoloaded options, and when you deactivate or delete the plugin, those settings often stay behind. I’ve written before about the plugin graveyard on the Plugins screen. This is the part of that graveyard you can’t see. A contact form plugin from three years ago, a slider you tried for a week, an SEO plugin you swapped out. Their settings can still be loaded on every page.
Since WordPress 6.6, the autoload setting also has more values than the old yes and no, so an older tool that only looks for yes or on can miss the newer ones and make the pile look smaller than it is.
To see what’s being loaded, you can ask WordPress itself with WP-CLI:
wp eval 'echo array_sum( array_map( "strlen", wp_load_alloptions() ) );'
It prints the total size, in bytes, of everything WordPress autoloads. To see the biggest single options:
wp option list --fields=option_name,autoload,size_bytes --orderby=size_bytes --order=desc
Then it’s a job of reading the names. If a big option clearly belongs to a plugin that isn’t installed any more, it’s a candidate for removal.
The tidy-up I do
I keep this deliberately slow and careful, because deleting the wrong row can break a site.
- Take a full backup first. Files and database, downloaded somewhere that isn’t the same server. Make sure you know how to restore it. If you have a staging copy, do the tidy-up there first.
- Measure before you touch anything. Count the revisions and check the size of the autoloaded options, so you can tell afterwards whether the tidy-up made a difference.
- Clear the expired transients.
wp transient delete --expiredis the least risky step, because those transients have already run out. - Trim the revisions. Cap them in
wp-config.php, then remove the backlog. I’ll check with the site owner first, in case someone is relying on an old version of a page. - Deal with leftover plugin options one at a time. Read the list, match each large option to a plugin, and only remove the ones you’re sure belong to a plugin that’s gone. If you’re not sure, leave it, or switch off its autoload instead of deleting it.
- Remove the plugins and themes you’re not using, rather than leaving them deactivated. That stops the graveyard growing back.
- Measure again, and test the site. Load the home page, a few inner pages, and wp-admin. Check forms and anything that saves data.
A tidy-up like this won’t fix a slow server or huge unoptimised images. It does take away the drag that builds up quietly over time.
Wrap Up
A WordPress site rarely gets slower for no reason. More often it’s collecting revisions, expired transients and settings from plugins that left years ago. None of it shows up on the front of the site, so it keeps growing until someone looks.
If your site feels a little slower every month and you’d like a second pair of eyes, book a quick call and we’ll look at what’s piling up and what I’d tidy first.
Written by Connie, an AI, from Neil Matthews’ notes, archive, and direction. Neil directed and edited this piece. He did not write these words. Augmented publishing by Neil Matthews.