CoreGamix — Full-Stack Engineering & Developer ToolsCoreGamix — Full-Stack Engineering & Developer Tools
  • Angular
  • Web Development
    • React & TypeScript
    • Node.js
    • PHP & MySQL
  • Tech & AI News
  • Tools & Plugins
  • About
  • Contact Us
HomeWeb Development WordPress Autoloaded Options: Fix Plugin Bloat, TTFB Spikes & Cache Evictions

WordPress Autoloaded Options: Fix Plugin Bloat, TTFB Spikes & Cache Evictions

Anil Mehra on December 2, 2026
Web Development Wordpress Plugins
WordPress autoloaded options architecture card showing wp_options payload reduction from 1.84 MB to 186 KB and TTFB drop
8 Min Read

Last month, a WooCommerce client’s P95 Time to First Byte jumped from 68ms to 412ms right after a plugin update, even though Redis was healthy and page queries hadn’t changed. When I profiled wp_load_alloptions(), I found WordPress autoloaded options had ballooned to 1.84 MB because three plugins were dumping sync logs and redirect maps into wp_options with autoload enabled. Trimming that payload down to 186 KB restored 68ms TTFB on the very next deployment.

Most database tuning tutorials still tell you to run WHERE autoload = 'yes' in phpMyAdmin and call it a day. However, that legacy query misses rows introduced since WordPress 6.6’s tri-state autoload engine, and manual edits break again as soon as a plugin re-saves its settings. Below, I’ll walk through the exact SQL audit, PHP write guards, and upgrade migration I ship in every production plugin—tested locally inside my ServBay local PHP and Redis environment before anything touches staging.

Why WordPress Autoloaded Options Trigger the 1 MB Cache Eviction Cliff

Every single WordPress request boots by calling wp_load_alloptions(). Rather than hitting MySQL twenty separate times for small settings like siteurl or active_plugins, core fetches every autoloaded row in one query and stores the combined array under a single alloptions object-cache key.

That single key hides a nasty cliff. Memcached caps individual cache items at 1 MB by default, while Redis slows down noticeably once PHP has to transfer and unserialize() megabytes of option strings on every worker hit. As a result, once your alloptions payload crosses 1 MB on Memcached, the cache silently rejects the write—forcing every concurrent HTTP request to hammer MySQL and spike PHP peak memory.

WordPress autoloaded options lifecycle diagram comparing unbounded alloptions cache eviction against selective wp_set_option_autoload_values
How unbounded plugin rows push wp_load_alloptions() past the 1 MB object-cache ceiling, versus keeping core flags lean at 186 KB and loading heavy options lazily.

Slow server boot kills frontend metrics too. Even if you pair aggressive edge caching with the Speculation Rules API for instant LCP, every logged-in admin click, checkout POST, or REST API call still pays the full alloptions unserialization tax. Therefore, keeping autoloaded data under 300 KB (and strictly below WordPress Site Health’s 800 KB warning threshold) protects both origin latency and worker concurrency.

Auditing WordPress Autoloaded Options Across WP 6.6+ Tri-State Values

Skip the outdated autoload = 'yes' snippet. According to the WordPress Core Options API dev note, WordPress 6.6 replaced binary yes/no writes with explicit and heuristic states: on, off, auto, auto-on, and auto-off. Because core now queries wp_autoload_values_to_autoload(), any audit that filters only for 'yes' will silently ignore newer bloated plugin rows stored as on or auto.

Instead, I run this two-part WP-CLI SQL check whenever I inherit a sluggish site. First, it sums the real byte weight of every row core actually loads; second, it ranks the twenty largest offenders so I know which plugin owns each bloated key:

-- 1. Measure total autoloaded payload across legacy and WP 6.6+ values
SELECT
  COUNT(*) AS autoload_rows,
  ROUND(SUM(LENGTH(option_value)) / 1024, 1) AS total_kb
FROM wp_options
WHERE autoload IN ('yes', 'on', 'auto', 'auto-on');

-- 2. List the 20 largest autoloaded keys for plugin attribution
SELECT
  option_name,
  ROUND(LENGTH(option_value) / 1024, 1) AS size_kb,
  autoload
FROM wp_options
WHERE autoload IN ('yes', 'on', 'auto', 'auto-on')
ORDER BY LENGTH(option_value) DESC
LIMIT 20;
WP-CLI SQL audit of WordPress autoloaded options showing tri-state values and P95 TTFB drop from 412ms to 68ms
Real-world WP-CLI audit catching legacy ‘yes’ alongside modern ‘on’ and ‘auto’ rows, cutting payload from 1,840 KB to 186 KB and P95 TTFB from 412ms to 68ms.

Look closely at what turned up in my client’s audit. A single sync log row (my_plugin_sync_logs) was marked on at 842.4 KB, while a legacy redirect map sat at 518.2 KB as yes and a widget cache consumed 294.0 KB as auto. Also, check whether your wp_options table actually has an index on the autoload column—older WordPress installs migrated before 5.3 sometimes lack it, which turns every boot query into a full table scan just like an unindexed offset query in MySQL pagination workloads.

Fixing Plugin Writes With Explicit Autoload Flags in PHP

Never trust default arguments when calling add_option() or update_option(). If you omit the autoload parameter, WordPress passes null and applies its 150 KB wp_max_autoloaded_option_size heuristic. That guardrail blocks a single 200 KB blob, whereas twenty separate 40 KB JSON payloads from your plugin will still sneak into alloptions and add 800 KB of dead weight.

Here’s the rule I enforce in code reviews: only autoload tiny feature flags needed on every frontend page view. Otherwise, pass false explicitly—as documented in the WordPress update_option() reference—for admin-only settings, sync logs, webhook histories, and cached API responses:

<?php
declare(strict_types=1);

namespace CoreGamix\SyncPlugin;

final class SettingsStore {
    private const FRONTEND_FLAGS_KEY = 'cgx_sync_frontend_flags';
    private const SYNC_LOG_KEY       = 'cgx_sync_audit_log';
    private const ADMIN_MAPPING_KEY  = 'cgx_sync_field_mappings';

    /**
     * Small array (< 2 KB) read on every frontend render: autoload = true.
     */
    public static function saveFrontendFlags(array $flags): bool {
        return update_option(self::FRONTEND_FLAGS_KEY, $flags, true);
    }

    /**
     * Admin-only schema mappings: never needed on public requests.
     */
    public static function saveAdminMappings(array $mappings): bool {
        return update_option(self::ADMIN_MAPPING_KEY, $mappings, false);
    }

    /**
     * Rolling log buffer: explicitly disable autoload and cap row growth.
     */
    public static function appendSyncLog(array $entry): bool {
        $logs = get_option(self::SYNC_LOG_KEY, []);
        if (!is_array($logs)) {
            $logs = [];
        }
        $logs[] = $entry;
        $logs   = array_slice($logs, -100);

        return update_option(self::SYNC_LOG_KEY, $logs, false);
    }
}

Notice one subtle trap with update_option(). If an option already exists in the database and its new value matches the existing value, WordPress short-circuits early and won’t update the autoload column at all. Consequently, fixing your write calls alone doesn’t heal sites that already installed an older version of your plugin.

Migrating Existing WordPress Autoloaded Options Safely on Upgrade

To clean up existing customer databases without rewriting option payloads, WordPress 6.4 introduced wp_set_option_autoload_values(). Rather than running raw $wpdb->update() queries that leave object caches stale, the official wp_set_option_autoload_values() API updates multiple rows in one atomic query and purges the alloptions cache key automatically.

In my plugins, I wire a versioned migration routine to admin_init so it executes exactly once per site upgrade and cleans up legacy rows safely:

<?php
declare(strict_types=1);

namespace CoreGamix\SyncPlugin;

final class AutoloadMigration {
    private const SCHEMA_OPTION = 'cgx_sync_db_version';
    private const TARGET_SCHEMA = '2.4.0';

    public static function maybeMigrate(): void {
        $current = (string) get_option(self::SCHEMA_OPTION, '0.0.0');
        if (version_compare($current, self::TARGET_SCHEMA, '>=')) {
            return;
        }

        $targets = [
            'cgx_sync_audit_log'      => false,
            'cgx_sync_field_mappings' => false,
            'cgx_sync_last_payload'   => false,
            'cgx_sync_frontend_flags' => true,
        ];

        if (function_exists('wp_set_option_autoload_values')) {
            wp_set_option_autoload_values($targets);
        } else {
            // Safe fallback for legacy installs running WordPress < 6.4.
            foreach ($targets as $key => $autoload) {
                $value = get_option($key, null);
                if ($value !== null) {
                    delete_option($key);
                    add_option($key, $value, '', $autoload ? 'yes' : 'no');
                }
            }
        }

        update_option(self::SCHEMA_OPTION, self::TARGET_SCHEMA, true);
    }
}

add_action('admin_init', [AutoloadMigration::class, 'maybeMigrate']);

In addition, always register an uninstall.php cleanup hook that calls delete_option() on every key your plugin created. Otherwise, sites that deactivate and delete your plugin remain saddled with orphaned rows forever.

Autoload Value Matrix: Legacy vs Modern wp_options Flags

When auditing mixed-age databases, you’ll see both legacy strings and modern WordPress 6.6+ flags side by side. Therefore, I keep this reference table handy during performance reviews so I know which rows actually enter alloptions:

Autoload Column ValueLoaded on Every Request?How WordPress Sets ItRecommended Plugin Action
yesYesLegacy WP < 6.6 default or explicit 'yes'Keep only for small global flags; migrate heavy keys to false
onYesExplicit true in WP 6.6+Use intentionally for tiny (< 5 KB) frontend config
auto / auto-onYesOmitted (null) parameter under 150 KB heuristicReplace omitted flags with explicit true or false
auto-offNoOmitted (null) parameter exceeding 150 KB limitMove data to a custom table or explicit false option
no / offNoExplicit false in legacy (no) or WP 6.6+ (off)Default choice for admin settings, logs, and batch caches

In short, any key growing unboundedly—such as audit logs, webhook queues, or analytics counters—doesn’t belong in wp_options at all. Instead, store growing event streams in a dedicated custom table with proper indexing so your core options table stays fast permanently.

Common Questions About WordPress Autoloaded Options

Does disabling autoload on an option slow down get_option() calls?

Not when you use it correctly. When an option is marked off, calling get_option() issues one indexed primary-key lookup (which takes under 0.3ms in MySQL) and caches that individual key in Redis or Memcached. Because admin-only settings are only read on settings screens, skipping autoload saves memory on 99% of frontend traffic while keeping admin pages snappy.

How large can alloptions safely grow before Site Health warns you?

WordPress Site Health flags a critical performance warning once total autoloaded bytes exceed 800 KB. However, I treat 300 KB as my engineering ceiling on production plugins, since leaving headroom prevents a single third-party update from pushing Memcached past its 1 MB slab limit during peak traffic.

Anil Mehra on December 2, 2026 Web Development Wordpress Plugins
previous article
Next article

View comments (1)

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *

About the Author

Anil Mehra

Anil Mehra

Software Engineer · Google AI Certified

Anil Mehra is a Software Engineer specializing in Angular (NgRx, SignalStore, RxJS), React, TypeScript, Node.js, PHP, and MySQL. Holding the Google AI Professional Certificate, he bridges production web architecture with practical AI-powered workflows.

Google AI Professional Certificate official badge

Google AI Professional Certificate

Google · Coursera Credential ↗

About & Consulting · Instagram · LinkedIn

Recent Guides

  • WordPress Block Bindings API guide banner showing custom PHP sources connected to Gutenberg block editor Attributes sidebar
    Block Bindings API in WordPress Plugins: PHP Sources, Editor UI & Batched LoopsDecember 2, 2026
  • WordPress autoloaded options architecture card showing wp_options payload reduction from 1.84 MB to 186 KB and TTFB drop
    WordPress Autoloaded Options: Fix Plugin Bloat, TTFB Spikes & Cache EvictionsDecember 2, 2026
  • claude sonnet 4.5 retirement migration guide banner
    Claude Sonnet 4.5 Retirement Hits Today: How I Migrated Node.js Calls to Sonnet 5.5November 30, 2026
  • speculation rules api instant prerender LCP guide banner
    Speculation Rules API Guide: Cut Route LCP to 38ms Without Phantom AnalyticsNovember 30, 2026

Engineering Topics

  • Angular 13
  • Frontend Development 4
  • Node.js 3
  • PHP & MySQL 2
  • React & TypeScript 2
  • SEO & Performance 2
  • Tech & AI News 4
  • Web Development 21
  • Wordpress Plugins 3
CoreGamix — Full-Stack Engineering & Developer ToolsCoreGamix — Full-Stack Engineering & Developer Tools

contact

support@coregamix.com

© 2026 CoreGamix. All Rights Reserved.  |  About  |  Privacy Policy  |  Terms of Use  |  Contact

Back to top