← All posts

How to Fix Bloated Autoloaded Options in WordPress and WooCommerce

A dark database cylinder overflowing with gears, puzzle pieces and plugin plugs, with an orange arrow pointing to a slim, tidy teal database on a balanced scale, a broom, a shopping cart and a speedometer

Last week I wrote about cleaning up Action Scheduler, the background queue that quietly grows into one of the biggest tables in a WooCommerce database. This week it’s the other table that slows stores down without anyone noticing: wp_options, and specifically the options WordPress loads on every single request.

If Site Health has ever told you that “autoloaded options could affect performance”, this is what it means and how I fix it on client sites.

What autoloaded options are

Every row in wp_options has an autoload column. On every page load, front end, admin, AJAX and REST, WordPress runs one query that pulls every autoloaded option into memory at once, so later calls to get_option() don’t hit the database.

That’s a good idea for small, frequently used settings like your site URL, active plugins and theme mods. It becomes a problem when plugins mark large or rarely used data as autoloaded: cached CSS, license data, import logs, stats, serialized arrays that grow over time. All of it is loaded on every request, including the checkout and the cart fragments call, whether it’s needed or not.

WordPress treats anything over 800 KB of autoloaded data as worth a look, and older WooCommerce stores with years of plugin churn often go well past that.

What changed in WordPress 6.6

WordPress 6.6 changed how autoload works, which matters when you start querying the table:

  • The old yes and no values were replaced by on, off and auto, plus auto-on and auto-off for options where WordPress made the decision itself. Older rows can still say yes or no, so check for all of them
  • When a plugin adds an option without saying whether it should autoload, WordPress now decides for it, and large values (over 150 KB by default) are no longer autoloaded
  • Site Health got a check that warns when autoloaded options pass 800 KB

That stops some new bloat, but it doesn’t touch rows that were already marked to autoload, and it doesn’t stop plugins that explicitly ask for autoload on large values.

Step 1: Back up and measure

Take a full database backup first. You’re about to change rows that every request depends on.

Then check the total size of autoloaded data. Adjust the wp_ prefix if your site uses a different one:

SELECT ROUND(SUM(LENGTH(option_value)) / 1024) AS autoload_kb, COUNT(*) AS options
FROM wp_options
WHERE autoload IN ('yes', 'on', 'auto-on', 'auto');

Write the number down. You’ll compare against it at the end.

Step 2: Find the biggest offenders

SELECT option_name, ROUND(LENGTH(option_value) / 1024, 1) AS kb, autoload
FROM wp_options
WHERE autoload IN ('yes', 'on', 'auto-on', 'auto')
ORDER BY LENGTH(option_value) DESC
LIMIT 30;

Usually a handful of rows make up most of the total. For each one, work out where it came from. The option name usually starts with the plugin’s prefix. If it doesn’t, search the codebase:

grep -rl "option_name_here" wp-content/plugins wp-content/themes wp-content/mu-plugins

Then sort each row into one of four buckets.

Step 3: Sort what you find

Core and active plugins that need it. active_plugins, rewrite_rules, cron, sidebars_widgets and similar are supposed to autoload. Leave them alone. If cron itself is huge, that’s a sign of orphaned or duplicated scheduled events, which is a separate fix.

Leftovers from plugins you removed. Most plugins don’t delete their settings on uninstall. If the grep finds nothing in your active code, the option is very likely dead weight. These are the safest wins.

Active plugins storing big data with autoload on. Caches, logs, stats and generated CSS often don’t need to load on every request. The plugin will still read them with get_option() when it needs them, it just costs one extra query at that point.

Transients. Rows starting with _transient_ or _site_transient_ are temporary cache. Expired ones can be cleared at any time, and on a site with a persistent object cache they shouldn’t be in this table at all.

Step 4: Clean up safely

Start with expired transients, which is always safe:

wp transient delete --expired

For big options from active plugins, switch autoload off rather than deleting anything. With WP-CLI:

wp option set-autoload some_plugin_cache off

Or in PHP, for example from a one-off script or a small mu-plugin (WordPress 6.4+):

wp_set_options_autoload(
    array( 'some_plugin_cache', 'some_plugin_stats' ),
    false
);

For leftovers from plugins you’ve removed, delete them once you’re sure nothing uses them:

wp option delete old_plugin_settings

Work in small batches. After each batch, load the front end, the admin, the cart and the checkout, and run a test order on staging before you repeat the change on production. If something breaks, set autoload back on or restore that one row from your backup.

One caution: some plugins re-save their options on the next settings change and turn autoload back on. If a row keeps coming back, raise it with the plugin’s developer instead of fighting it with code.

Step 5: Why this matters even with Redis

A common answer is “we have Redis, so it doesn’t matter”. Partly true. With a persistent object cache, WordPress stores all autoloaded options as a single alloptions cache entry instead of querying the database each time.

But that entry is still read, unserialized and held in PHP memory on every request. And if it grows past your cache’s item size limit (Memcached’s default is 1 MB), it can fail to store at all, so every request falls back to the database query you were trying to avoid. A smaller autoload set makes the object cache work better, not less.

Step 6: Keep it lean

Measure again with the query from Step 1 and compare. Then make it part of routine maintenance:

  • Check the Site Health status screen once a month
  • Re-run the top 30 query after installing or removing plugins
  • Delete expired transients on a schedule, or let a persistent object cache handle them
  • When you remove a plugin, check whether it left large options behind

If you manage several sites, this is exactly the kind of check worth running across the whole fleet rather than one site at a time.

FAQ

What is a good size for autoloaded options?

Under 800 KB, which is the threshold WordPress’s own Site Health check uses. Lower is better, as long as you’re not switching off options that are needed on every page.

Is it safe to set autoload to off?

For options that aren’t needed on every page, yes. The value stays in the database and get_option() still returns it, it just costs one extra query when it’s used. Don’t turn it off for core options like active_plugins or siteurl.

Can I delete options from plugins I’ve uninstalled?

Usually yes, once you’ve confirmed no active plugin or theme uses them. Back up first, and delete in batches so you can tell which change caused a problem if one does.

Will this make my WooCommerce store faster?

It reduces the work done on every uncached request: the admin, the cart, the checkout and logged-in customers. The bigger the autoload set was, the more you’ll notice it.

Need a hand?

If Site Health is flagging autoloaded options and you’re not sure what’s safe to change, I can audit the database, clean it up on staging first, and set up a routine so it stays lean. Get in touch or see my services.

Agency looking after a fleet of WordPress and WooCommerce sites? Betatech works as your white-label WordPress team, NDA included.

Questions about this post?

Or a store that needs the same kind of work? Send me a message and I’ll reply within one business day.