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

- On every uncached WordPress request,
wp_load_alloptions()pulls every row inwp_optionsmarkedautoload IN ('yes', 'on', 'auto-on', 'auto')into PHP RAM at once—above800 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 ofcomplete,canceled, andfailedrows insidewp_actionscheduler_actionsandwp_actionscheduler_logs. - Never run raw
TRUNCATE wp_actionscheduler_actionsor blindDELETE FROM wp_commentsSQL from blog snippets—doing so wipes recurring subscription renewals and WooCommerceorder_noteaudit trails!
Table of Contents (10 sections)
- How wp_load_alloptions() Turns a 4 MB Table Into a CPU Furnace
- Step 1: Audit Your Top 15 Autoloaded Offenders Safely
- How to Classify Each Offender in the Top 20 List
- Step 2: Why wp_actionscheduler_actions and wp_actionscheduler_logs Explode to Millions of Rows
- Why Raw TRUNCATE SQL Snippets Break Live WooCommerce Stores
- How KadiCache Cleans Action Scheduler & Transients With Surgical Safety (DatabaseCleanupItems.php)
- Step-by-Step Safe Cleanup Workflow via WP-CLI (Cli/DatabaseCli.php)
- Step 3: Sweeping Orphaned wp_postmeta, wp_commentmeta & Term Relationships Safely
- Step 4: Reclaiming Disk & InnoDB Buffer Pool Space After Deleting Millions of Rows
- Multisite wp_sitemeta & Shared notoptions Cache Hygiene
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 Payload | Typical Row Count | Per-Request PHP unserialize() Cost | Impact on /wp-admin/ & /checkout/ | Health Verdict |
|---|---|---|---|---|
| 180 KB – 450 KB | 150 – 380 rows | 1.2 – 3.5 ms | Instantaneous | Optimal |
| 450 KB – 800 KB | 380 – 650 rows | 3.5 – 8.0 ms | Healthy for WooCommerce + Multilingual | Healthy (<= 800 KB) |
| 800 KB – 2.5 MB | 650 – 2,200 rows | 18 – 65 ms (+ 12 MB PHP RAM/worker) | Noticeable admin & cart lag | Warning — Audit Top 15 |
| 2.5 MB – 12+ MB | 2,200 – 18,000 rows | 90 – 480 ms (+ MySQL sort/packet stalls) | Checkout timeouts & Redis OOM evictions | Critical Bloat |
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):
# Lists total autoloaded KB, row count, and Top 15 options with attributed plugin source
wp kadicache object-cache infoOr, if you only have MySQL / WP-CLI db query access during an outage, run the WordPress 6.6+ compatible read-only diagnostic query:
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:
- 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 withwp option delete old_plugin_cache.
- 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.
- Expired Transients Without an External Object Cache (
Clean via KadiCache Database Tab): When noobject-cache.phpdrop-in is active, WordPress writes transients towp_options(_transient_*and_transient_timeout_*). Expired transients with missing timeout pairs linger indefinitely until swept.
- Core
rewrite_rulesorcronBloat (Fix the Generator, Not the Flag): Keeprewrite_rulesautoloaded, but ifrewrite_rulesexceeds300 KB, check whether a custom post type or taxonomy generated thousands of redundant per-post rewrite regexes. Ifcronexceeds150 KB, a buggy plugin is scheduling duplicate single events without checkingwp_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.
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_paymentactions (silently stopping recurring subscription billing!).
- In-progress
claim_id != 0workers 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:
- Strict Status, Age & Live-Claim Verification (
actionEligible()): KadiCache never touchespendingorin-progressactions. It cleanscompleteandcanceledactions only after 7+ days of inactivity, and retainsfailedactions for 30 full days so you never lose recent failure diagnostics—while joiningwp_actionscheduler_claims(c.claim_id IS NULL) and re-verifyingNOT EXISTSrecentwp_actionscheduler_logsright before callingActionScheduler::store()->delete_action($id)(which cascades log deletion cleanly through Action Scheduler's own store contract!).
- Keeping Action Scheduler Args Tiny (
ActionSchedulerJobs::schedulePurge()): Notice lines 172–192 ofActionSchedulerJobs.php: whenever KadiCache itself schedules a batch invalidation whose JSON payload exceeds6,000bytes, it stores the payload in a non-autoloaded (autoload = false) option (kadicache_action_payload_*) swept automatically by a bounded2-secondkeyset cursor (expirePayloads()) rather than bloatingwp_actionscheduler_actions.argsorwp_optionsautoload!
- 100% WooCommerce
order_note&shop_orderImmunity: Naive comment/revision cleaners accidentally wipe WooCommerce payment audit notes (comment_type = 'order_note') or trashed orders.DatabaseCleanupItems::postTypes()explicitly excludesshop_order,shop_subscription,edd_payment, andattachment, and every comment/revision SQL query enforcescomment_type <> 'order_note'.
- Open Editor Lock Protection (
postLocked()): Before removing an old revision or auto-draft, KadiCache checkswp_check_post_lock()so an editor currently working in Gutenberg never loses an active autosave.
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:
# 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 infoSchedule 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?
- Unbounded Full-Table Locks: Running a single monolithic
DELETEacross 1.8 millionwp_postmetarows holds InnoDB row/gap locks across the entire table, freezing concurrent WooCommercecheckoutorder inserts until the query finishes.
- TOCTOU (Time-of-Check to Time-of-Use) Race Conditions: If a cleanup plugin scans candidate
meta_idvalues at10:00:01and deletes them by ID at10:00:04without re-verifying ownership inside theDELETEstatement, 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:
-- 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,000rows for meta,<= 200composite pairs forwp_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 EXISTSRe-Verification InsideDELETE: Even if an owner row appeared milliseconds after candidate discovery, MySQL re-checksNOT EXISTSatomically during deletion. - Strict Post-Taxonomy Scoping (
postTaxonomies()): Custom link or user taxonomies sharingwp_term_relationships(object_idpointing towp_usersrather thanwp_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 Situation | DATA_FREE Fragmentation | Recommended MySQL / WP-CLI Action | Locks Writes During Run? |
|---|---|---|---|
Normal weekly KadiCache cleanup (< 50 MB freed) | Low (< 15%) | Do nothing! InnoDB automatically reuses freed pages for new inserts | Zero lock |
One-time cleanup after removing 1M+ Action Scheduler rows | High (> 500 MB DATA_FREE) | Run ALTER TABLE wp_actionscheduler_logs ENGINE=InnoDB, ALGORITHM=INPLACE, LOCK=NONE; during off-peak window | Online DDL (LOCK=NONE on MySQL 8 / MariaDB 10.6+) |
Small bloated wp_options table (45 MB -> 2 MB live data) | Severe scan bloat | Run wp db optimize (or ALTER TABLE wp_options ENGINE=InnoDB;) during a 3-second low-traffic window | Brief 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_*inwp_sitemeta): KadiCache cleans network-wide site transients only from the main site undermanage_network_options/ CLI / cron privileges (canCleanSiteTransients()), scoping queries strictly tosite_id = get_current_network_id(). - Clearing
notoptionsCache After Direct Option Deletions: Whenever WordPress checks an option that does not exist, it cachestrueinside theoptions:notoptionshash so repeatedget_option()calls do not hit MySQL. KadiCache explicitly invalidates both the option key andnotoptions(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?
Why did WordPress 6.6 add new autoload values like on, auto-on, and auto alongside yes?
Is it safe to run TRUNCATE TABLE wp_actionscheduler_actions when the table hits 2 GB?
Why do naive database cleaner plugins accidentally delete WooCommerce order notes?
Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.
8 bounded cleanup targets with order_note protection, editor lock checks, and receipts.
Run dry-run inspections, scheduled cleanups, and WP-CLI database maintenance safely.
Inspect top 15 autoloaded options and eliminate alloptions race conditions.
How wp_options deserialization and MySQL buffer pool pressure inflate dynamic TTFB.