Skip to main content
KadiCache
Engineering Journal · WooCommerce9 min read1,896 wordsVerified 2026-11-23

Fix Autoloaded Options WordPress & Action Scheduler

Audit bloated autoloaded options WordPress tables above 800 KB and clean millions of Action Scheduler rows safely.

Filtering a bloated 8.4 MB wp_options database table down to a fast 240 KB autoload footprint
0.000 Layout Shift10 Sections✓ Verified
⚡ Executive Summary · 30-Second Spec100% Code-Verified
WP Admin Path
WP Admin -> KadiCache -> Database + Object Cache
Measured Impact
< 800 KB Healthy Autoload Budget · Zero WooCommerce Order-Note Loss
DevTools Proof Marker
wp kadicache object-cache info | wp kadicache db status
  • On every uncached WordPress request, wp_load_alloptions() pulls every row in wp_options marked autoload IN ('yes', 'on', 'auto-on', 'auto') into PHP RAM at once—above 800 KB (HEALTH_LIMIT_BYTES = 819200), deserialization alone stalls TTFB by 80–450 ms.
  • Uninstalled plugins routinely abandon multi-megabyte serialized arrays in wp_options, while WooCommerce + SEO plugins accumulate millions of complete, canceled, and failed rows inside wp_actionscheduler_actions and wp_actionscheduler_logs.
  • Never run raw TRUNCATE wp_actionscheduler_actions or blind DELETE FROM wp_comments SQL from blog snippets—doing so wipes recurring subscription renewals and WooCommerce order_note audit trails!
Table of Contents (10 sections)

Bloated autoloaded options WordPress rows (wp_options) and multi-gigabyte wp_actionscheduler_actions / wp_actionscheduler_logs tables are the silent killers of mature 2-to-5-year-old WooCommerce stores. Unlike missing image compression—which only slows down a single page—wp_options autoload bloat taxes every single uncached PHP request across your entire site: /checkout/, /wp-admin/, REST API webhooks, and wp-cli jobs alike.

How wp_load_alloptions() Turns a 4 MB Table Into a CPU Furnace#

Early in every WordPress bootstrap (wp-includes/option.php), WordPress executes wp_load_alloptions(). Instead of querying options one by one, it fetches every row marked for autoloading in a single query and calls maybe_unserialize() across them in PHP memory.

Note an important WordPress 6.6+ change that catches legacy tutorials off guard: autoloaded rows no longer use only autoload = 'yes'. Modern WordPress core uses wp_autoload_values_to_autoload(), which evaluates ['yes', 'on', 'auto-on', 'auto']! If you run an outdated 2021 SQL snippet checking WHERE autoload = 'yes', you can completely miss a 3.2 MB plugin array stored under autoload = 'on' or 'auto'.

Inside Cache/ObjectCache/AutoloadAnalyzer.php, KadiCache queries the exact active core autoload set and flags HEALTH_LIMIT_BYTES = 819200 (800 KB):

Total Autoloaded PayloadTypical Row CountPer-Request PHP unserialize() CostImpact on /wp-admin/ & /checkout/Health Verdict
180 KB – 450 KB150 – 380 rows1.2 – 3.5 msInstantaneousOptimal
450 KB – 800 KB380 – 650 rows3.5 – 8.0 msHealthy for WooCommerce + MultilingualHealthy (<= 800 KB)
800 KB – 2.5 MB650 – 2,200 rows18 – 65 ms (+ 12 MB PHP RAM/worker)Noticeable admin & cart lagWarning — Audit Top 15
2.5 MB – 12+ MB2,200 – 18,000 rows90 – 480 ms (+ MySQL sort/packet stalls)Checkout timeouts & Redis OOM evictionsCritical Bloat
FIG 01Configure Redis/Relay/SQLite parameters alongside Smart Route Prefetching, Atomic Split Alloptions, and zstd/igbinary compression.Zoom 2x

Step 1: Audit Your Top 15 Autoloaded Offenders Safely#

Never run UPDATE wp_options SET autoload = 'off' blindly across rows you have not identified! Turning autoload = 'off' on an option that WordPress actually reads on every single page load (like active_plugins, wp_user_roles, or woocommerce_currency) simply trades 1 batched query for 50 separate SELECT option_value FROM wp_options WHERE option_name = ... queries on every request!

First, inspect your exact Top 15 largest autoloaded rows either inside WP Admin -> KadiCache -> Object Cache or via WP-CLI (Cli/ObjectCacheCli.php):

BASH
# Lists total autoloaded KB, row count, and Top 15 options with attributed plugin source
wp kadicache object-cache info

Or, if you only have MySQL / WP-CLI db query access during an outage, run the WordPress 6.6+ compatible read-only diagnostic query:

SQL
SELECT option_name,
       ROUND(OCTET_LENGTH(option_value) / 1024, 1) AS size_kb,
       autoload
FROM wp_options
WHERE autoload IN ('yes', 'on', 'auto-on', 'auto')
ORDER BY OCTET_LENGTH(option_value) DESC
LIMIT 20;

How to Classify Each Offender in the Top 20 List#

Every bloated row falls into one of four clear buckets:

  1. Orphaned Data From Uninstalled Plugins (Safe to Delete After Backup): Old page builders, redirect logs stored inside a single option (redirection_logs, old security scanner snapshots, deactivated slider caches, abandoned theme demo importers). Export a single-row backup (wp option get old_plugin_cache > backup.json) and remove with wp option delete old_plugin_cache.
  1. Admin-Only / Infrequent Plugin Arrays (Safe to Set autoload = off): Huge changelog arrays, license telemetry caches, admin notice histories, or import mapping tables that are never needed on public frontend views. Flip autoload off cleanly without deleting data: wp option set-autoload some_admin_only_blob off.
  1. Expired Transients Without an External Object Cache (Clean via KadiCache Database Tab): When no object-cache.php drop-in is active, WordPress writes transients to wp_options (_transient_* and _transient_timeout_*). Expired transients with missing timeout pairs linger indefinitely until swept.
  1. Core rewrite_rules or cron Bloat (Fix the Generator, Not the Flag): Keep rewrite_rules autoloaded, but if rewrite_rules exceeds 300 KB, check whether a custom post type or taxonomy generated thousands of redundant per-post rewrite regexes. If cron exceeds 150 KB, a buggy plugin is scheduling duplicate single events without checking wp_next_scheduled()!

Step 2: Why wp_actionscheduler_actions and wp_actionscheduler_logs Explode to Millions of Rows#

WooCommerce, WooCommerce Subscriptions, Stripe/PayPal webhooks, Rank Math, WPForms, and KadiCache itself use Action Scheduler as WordPress's durable background job queue (wp_actionscheduler_actions, wp_actionscheduler_logs, wp_actionscheduler_claims, wp_actionscheduler_groups).

On an active WooCommerce store processing 400 orders/day plus inventory syncs and marketing webhooks, Action Scheduler easily records 30,000 to 120,000 actions and 350,000 log entries per week. If default WP-Cron retention falls behind—or if a failing third-party webhook retries every 5 minutes for six months—wp_actionscheduler_logs swells past 4 GB, slowing backups, increasing InnoDB buffer pool churn, and stalling admin screens.

FIG 02Bounded-batch Database Cleanup with live category counts, revision retention cap, and automated scheduling.Zoom 2x

Why Raw TRUNCATE SQL Snippets Break Live WooCommerce Stores#

Many dangerous tutorials tell store owners to run TRUNCATE TABLE wp_actionscheduler_actions; TRUNCATE TABLE wp_actionscheduler_logs; in phpMyAdmin. Never do that on a live store! Truncating wp_actionscheduler_actions permanently deletes:

  • Pending woocommerce_scheduled_subscription_payment actions (silently stopping recurring subscription billing!).
  • In-progress claim_id != 0 workers currently mid-flight.
  • Recent failed webhook logs needed by your payment engineer to replay a failed Stripe or ERP sync.

How KadiCache Cleans Action Scheduler & Transients With Surgical Safety (DatabaseCleanupItems.php)#

Look at the exact engineering guards inside Support/DatabaseCleanupItems.php and Support/ActionSchedulerJobs.php in KadiCache Free Core:

  1. Strict Status, Age & Live-Claim Verification (actionEligible()): KadiCache never touches pending or in-progress actions. It cleans complete and canceled actions only after 7+ days of inactivity, and retains failed actions for 30 full days so you never lose recent failure diagnostics—while joining wp_actionscheduler_claims (c.claim_id IS NULL) and re-verifying NOT EXISTS recent wp_actionscheduler_logs right before calling ActionScheduler::store()->delete_action($id) (which cascades log deletion cleanly through Action Scheduler's own store contract!).
  1. Keeping Action Scheduler Args Tiny (ActionSchedulerJobs::schedulePurge()): Notice lines 172–192 of ActionSchedulerJobs.php: whenever KadiCache itself schedules a batch invalidation whose JSON payload exceeds 6,000 bytes, it stores the payload in a non-autoloaded (autoload = false) option (kadicache_action_payload_*) swept automatically by a bounded 2-second keyset cursor (expirePayloads()) rather than bloating wp_actionscheduler_actions.args or wp_options autoload!
  1. 100% WooCommerce order_note & shop_order Immunity: Naive comment/revision cleaners accidentally wipe WooCommerce payment audit notes (comment_type = 'order_note') or trashed orders. DatabaseCleanupItems::postTypes() explicitly excludes shop_order, shop_subscription, edd_payment, and attachment, and every comment/revision SQL query enforces comment_type <> 'order_note'.
  1. Open Editor Lock Protection (postLocked()): Before removing an old revision or auto-draft, KadiCache checks wp_check_post_lock() so an editor currently working in Gutenberg never loses an active autosave.
FIG 03Post-cleanup execution receipt logs removed rows, batch count, elapsed duration, and proportional category share.Zoom 2x

Step-by-Step Safe Cleanup Workflow via WP-CLI (Cli/DatabaseCli.php)#

Always run a --dry-run inspection first, then execute bounded background cleanup and enable split_alloptions in KadiCache Object Cache:

BASH
# 1. Inspect current candidate counts without deleting a single row
wp kadicache db clean --items=revisions,auto_drafts,transients,actions,orphans --dry-run

# 2. Queue bounded, lock-safe cleanup in the background
wp kadicache db clean --items=revisions,auto_drafts,transients,actions,orphans

# 3. Check cleanup progress and receipt summary as JSON or table
wp kadicache db status

# 4. Verify autoloaded wp_options sits cleanly under the 800 KB health ceiling
wp kadicache object-cache info

Schedule automatic weekly maintenance inside WP Admin -> KadiCache -> Database (documented in our Database & Action Scheduler guide), and autoloaded options WordPress bloat will never creep back above 800 KB again.

Step 3: Sweeping Orphaned wp_postmeta, wp_commentmeta & Term Relationships Safely#

Once wp_options autoload and wp_actionscheduler_* are clean, a mature WooCommerce database often hides a third multi-hundred-megabyte anchor: orphaned metadata rows left behind when bulk CSV product imports, old coupon generators, or third-party scripts deleted posts via raw SQL without calling wp_delete_post().

Why do naive DELETE FROM wp_postmeta WHERE post_id NOT IN (SELECT ID FROM wp_posts) snippets lock production MySQL tables for minutes—or worse, delete live metadata created mid-run?

  1. Unbounded Full-Table Locks: Running a single monolithic DELETE across 1.8 million wp_postmeta rows holds InnoDB row/gap locks across the entire table, freezing concurrent WooCommerce checkout order inserts until the query finishes.
  1. TOCTOU (Time-of-Check to Time-of-Use) Race Conditions: If a cleanup plugin scans candidate meta_id values at 10:00:01 and deletes them by ID at 10:00:04 without re-verifying ownership inside the DELETE statement, any concurrent import or post save reusing an ID can lose fresh metadata.

Look at how DatabaseCleanupItems::removeOrphans() in KadiCache Free Core eliminates both hazards:

SQL
-- Verified pattern from KadiCache\Support\DatabaseCleanupItems::removeOrphans()
DELETE FROM wp_postmeta
WHERE meta_id IN (/* bounded batch of <= 1,000 primary keys */)
  AND post_id > 0
  AND NOT EXISTS (
    SELECT 1 FROM wp_posts WHERE ID = wp_postmeta.post_id
  )
LIMIT 1000;

Notice three defensive engineering details in that single statement:

  • Bounded Primary-Key Cursor Batches (<= 1,000 rows for meta, <= 200 composite pairs for wp_term_relationships): Each batch finishes in single-digit milliseconds so live WooCommerce orders never wait behind a table lock—and stays cleanly below SQLite's expression-depth ceiling on Playground/SQLite sites!
  • Atomic NOT EXISTS Re-Verification Inside DELETE: Even if an owner row appeared milliseconds after candidate discovery, MySQL re-checks NOT EXISTS atomically during deletion.
  • Strict Post-Taxonomy Scoping (postTaxonomies()): Custom link or user taxonomies sharing wp_term_relationships (object_id pointing to wp_users rather than wp_posts!) are never misclassified as orphaned post relationships.

Step 4: Reclaiming Disk & InnoDB Buffer Pool Space After Deleting Millions of Rows#

Here is a MySQL / MariaDB surprise that confuses many site owners: after deleting 2.5 million old rows from wp_actionscheduler_logs and 800 KB of dead transients from wp_options, SELECT DATA_FREE FROM information_schema.TABLES shows 1.9 GB of free fragmented pages, yet your .ibd file on disk is still the exact same size!

Table Maintenance SituationDATA_FREE FragmentationRecommended MySQL / WP-CLI ActionLocks Writes During Run?
Normal weekly KadiCache cleanup (< 50 MB freed)Low (< 15%)Do nothing! InnoDB automatically reuses freed pages for new insertsZero lock
One-time cleanup after removing 1M+ Action Scheduler rowsHigh (> 500 MB DATA_FREE)Run ALTER TABLE wp_actionscheduler_logs ENGINE=InnoDB, ALGORITHM=INPLACE, LOCK=NONE; during off-peak windowOnline DDL (LOCK=NONE on MySQL 8 / MariaDB 10.6+)
Small bloated wp_options table (45 MB -> 2 MB live data)Severe scan bloatRun wp db optimize (or ALTER TABLE wp_options ENGINE=InnoDB;) during a 3-second low-traffic windowBrief metadata lock (< 1–2s on 2 MB live rows)

Why does defragmenting a severely bloated wp_options table after a one-time cleanup drop dynamic TTFB immediately? Because InnoDB caches 16 KB pages—not individual rows—inside innodb_buffer_pool_size. Packing 600 KB of active options into 40 contiguous 16 KB pages instead of scattering them across 2,800 half-empty pages keeps 100% of wp_options hot in MySQL RAM.

Multisite wp_sitemeta & Shared notoptions Cache Hygiene#

If you operate a WordPress Multisite network, remember two extra guardrails already built into DatabaseCleanupItems.php and ActionSchedulerJobs.php:

  • Network Site Transients (_site_transient_timeout_* in wp_sitemeta): KadiCache cleans network-wide site transients only from the main site under manage_network_options / CLI / cron privileges (canCleanSiteTransients()), scoping queries strictly to site_id = get_current_network_id().
  • Clearing notoptions Cache After Direct Option Deletions: Whenever WordPress checks an option that does not exist, it caches true inside the options:notoptions hash so repeated get_option() calls do not hit MySQL. KadiCache explicitly invalidates both the option key and notoptions (wp_cache_delete('notoptions', 'options')) whenever deferred purge payloads are cleaned up, ensuring zero stale state between MySQL and KadiCache Object Cache.

Frequently Asked Engineering Questions

What is a healthy autoloaded wp_options size in WordPress 6.6+ and WooCommerce?
WordPress Site Health and KadiCache AutoloadAnalyzer.php enforce an 800 KB ceiling (HEALTH_LIMIT_BYTES = 819200 bytes). Well-maintained brochure sites sit between 180 KB and 420 KB, while healthy WooCommerce stores typically sit between 350 KB and 750 KB.
Why did WordPress 6.6 add new autoload values like on, auto-on, and auto alongside yes?
WordPress 6.6 standardized autoload flags so core can distinguish explicit developer intent (on / off) from automatic heuristics (auto / auto-on / auto-off). Older SQL queries checking only WHERE autoload = "yes" miss bloated rows in modern WordPress—which is why AutoloadAnalyzer::inspect() queries wp_autoload_values_to_autoload() dynamically.
Is it safe to run TRUNCATE TABLE wp_actionscheduler_actions when the table hits 2 GB?
No! Truncating wp_actionscheduler_actions destroys pending and in-progress hooks—including WooCommerce Subscriptions renewal charges, webhook deliveries, membership expirations, and queued cache purges. Only completed/canceled rows older than 7 days and failed rows older than 30 days with zero live claims should be pruned.
Why do naive database cleaner plugins accidentally delete WooCommerce order notes?
Because WooCommerce stores private payment gateway logs and customer order history inside wp_comments with comment_type = "order_note"! Look at DatabaseCleanupItems.php in KadiCache: every comment and post query explicitly excludes comment_type = "order_note", shop_order, and shop_subscription.
Verified WordPress Architecture · WooCommerce
Apply these exact optimizations on your WordPress or WooCommerce site in 2 minutes.
E-E-A-T Source Verified

Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.

Cache/ObjectCache/AutoloadAnalyzer.phpSupport/DatabaseCleanupItems.phpSupport/ActionSchedulerJobs.phpCli/DatabaseCli.php
Connected Topical Cluster · Continue Deepening Your Setup