☰
WORDPRESS / PRACTICE

WordPress Autoloaded Options Audit: How to Find and Reduce Unnecessary Load

WordPress Autoloaded Options Audit: How to Find and Reduce Unnecessary Load

WordPress loads autoloaded options while preparing a request, before most plugins and themes are executed. If the `wp_options` table has accumulated large settings, operational data, or leftovers from removed extensions, they can increase memory usage, object cache load, and request processing time.

The goal of an audit is not simply to find the largest records, but to understand which component owns them and whether they are needed on every request. Deleting an option incorrectly can break a plugin, theme, or part of the WordPress administration area, so make changes gradually, create a backup, and test everything on staging.

What Are Autoloaded Options and Why Do They Matter?

WordPress stores options in the `wp_options` table. The `autoload` field determines whether a value should be loaded automatically during WordPress initialization. The traditional values were `yes` and `no`, but modern WordPress versions may also contain `auto`, `auto-on`, and `auto-off`. The exact behavior depends on the WordPress version and how the option was created by a plugin.

All autoloaded values are combined into a dataset that WordPress retrieves from the database and caches in memory. With a persistent object cache, this dataset may be retained between requests, but that does not eliminate the problem of excessive size: the cache still has to be populated, transferred, and processed.

A large autoloaded dataset alone does not prove that a site is slow. Context and behavior matter: the total size, number of records, database performance, available memory, and whether the data is genuinely needed on every request.

  • Autoloaded options affect not only the pages where a particular plugin runs, but potentially every WordPress request.
  • Serialized arrays can be considerably larger than the number of settings they contain might suggest.
  • After a plugin is removed, its options may remain in the database and continue to be loaded automatically.

How to Find the Largest Autoloaded Options

Before starting the audit, identify the actual table prefix used by the site. The examples below use `wp_options`, but the table may have a different name. Run the command from the WordPress root directory, where WP-CLI is available.

For a more complete check, include all commonly used values that indicate automatic loading. The `auto` value may be handled separately in different WordPress versions, so check the WordPress version and the current behavior on staging before making changes.

  • Compare not only the largest records but also the total size of all autoloaded data.
  • Review several dozen records, because the problem may be caused not by one large value but by hundreds of medium-sized ones.
  • The `OCTET_LENGTH` result shows the value size in bytes, not necessarily the exact amount of memory used after PHP unserializes and processes it.
wp db query "SELECT option_name, autoload, OCTET_LENGTH(option_value) AS bytes FROM wp_options WHERE autoload IN ('yes','on','auto','auto-on') ORDER BY bytes DESC LIMIT 50;"

wp db query "SELECT COUNT(*) AS options_count, SUM(OCTET_LENGTH(option_value)) AS total_bytes FROM wp_options WHERE autoload IN ('yes','on','auto','auto-on');"

What Else to Check in the Results

Review the option names, autoload status, and size. The name often contains a plugin prefix, but this is not guaranteed: a plugin may use a generic or abbreviated name.

For more precise analysis, check whether the value contains a serialized array, large cache, task list, or logs. Do not edit such data manually in SQL: damaging the serialization can cause errors when `get_option()` is called.

  • A record of several kilobytes is not necessarily a problem if it is needed on every request.
  • Large key lists, page caches, import logs, and temporary data are more likely to be candidates for additional analysis.
  • Do not change WordPress system options, active theme settings, or data belonging to popular plugins without understanding their purpose.

How to Identify Who Owns an Option

The most difficult part of an audit is determining which component created and updates a record. Start with the option name: search for its prefix in the code of active plugins and the theme. File search tools such as `grep` are useful for this, as is reviewing the extension's source code.

If the name does not provide an answer, check the plugin documentation, its activation and deactivation functions, and locations where `add_option()`, `update_option()`, and `register_setting()` are called. On staging, you can temporarily deactivate a suspected plugin and run the query again, but first make sure you have a way to restore the site.

Sometimes an option was created by a plugin that has already been removed. In that case, check backups, deployment history, and the names of former extensions. An unknown record should not be deleted merely because its name is unfamiliar.

  • Compare audit results before and after deactivating a plugin on staging.
  • Check whether the option belongs to a multisite installation or shared configuration used by several components.
  • If a plugin updates the option on every request, the problem may quickly return after it is cleaned up.
grep -R "назва_опції" wp-content/plugins wp-content/themes --exclude='*.min.js' --exclude='*.css'

How to Safely Disable Autoloading

If the option is known, its owner has been verified, and the data is needed only on specific pages, you can change its status through the WordPress API. The third parameter of `update_option()` controls autoloading; setting it to `false` disables autoloading for that option.

The command below preserves the current value but changes how it is loaded. It should be used only for a specific, known option. If the option does not exist or legitimately returns `false` as its value, this approach requires additional verification.

  • Before making a change, create a database backup or export the relevant record.
  • Apply the change on staging first and test the homepage, forms, authentication, cart, checkout, and administration area.
  • After deployment, repeat the audit: a plugin may restore autoloading during an update, activation, or migration.
wp eval 'update_option("plugin_option", get_option("plugin_option"), false);'

When You Should Not Change Autoloading Manually

Do not change an option's status if it is unclear how the plugin reads it. Some extensions expect configuration to be available during WordPress's early initialization. After autoloading is disabled, the site may continue to work, but individual hooks, cron jobs, or administrative functions may behave differently.

Do not use a direct `DELETE` to remove unknown records. Deletion is a separate action that should be performed only after confirming that the data is no longer needed and that the plugin provides a proper cleanup mechanism.

  • For an unwanted plugin, use its standard uninstall mechanism first, if one is provided.
  • Do not remove every record with the same prefix without checking: a plugin may store important settings alongside temporary data.
  • After making changes, clear the object cache only according to your infrastructure's procedures and verify the result with a new query.

How to Evaluate the Result After Optimization

Run the SQL queries again after making the change and compare the total number of bytes, record count, and list of the largest options. This will show whether autoloading itself changed, rather than only the database cache state.

Next, test the site as an anonymous user and as an authenticated administrator. Separately test pages where the plugin that owns the option is active. Enable error logging on staging or review PHP-FPM, web server, and WordPress logs.

For an objective comparison, test the same pages under the same conditions: with warmed and cold caches, the same active plugins, and no parallel server configuration changes. Autoloading is only one factor affecting performance.

  • Make sure no PHP warnings, notices, fatal errors, or AJAX errors have appeared.
  • Check cron jobs, import queues, integrations, and background tasks if the plugin uses them.
  • Record the option name, previous size, new status, and change date to simplify rollback and future audits.

Common Audit Mistakes

The most common mistake is relying on a single arbitrary size threshold. There is no universal value at which every autoloaded option should be disabled. On a small site, dozens of small options may be less problematic than one large cache, but the final decision depends on the plugin's code.

The second mistake is deleting options without a backup or staging test. Even if a record belongs to a deactivated plugin, it may contain settings needed if the plugin is activated again.

You should also avoid confusing autoload cleanup with general database cleanup. Reducing the size of autoloaded data does not replace query optimization, caching configuration, cron management, or the removal of unnecessary transient data.

  • Do not analyze only `wp_options`: in multisite, site options are stored in separate tables, while network options are stored in a table such as `wp_sitemeta`.
  • Do not edit serialized values through ordinary copying or manual text replacement.
  • Do not assume that deactivating a plugin automatically removes all of its data.
  • Do not rely on a single speed test; also check functionality and logs.

Frequently asked questions

What size of autoloaded options is considered normal?

There is no single safe threshold for every site. Evaluate the total size, number of records, available memory, caching setup, and actual impact on requests. A large record should be investigated, but not necessarily disabled immediately.

Can I simply delete large options from the wp_options table?

You should not. First identify the owner, create a backup, and check whether the plugin has a standard cleanup process. As a first step, disabling autoloading is often safer than deleting the data.

Why did the problem return after I changed autoloading?

The plugin may have saved the option with autoloading enabled again during an update, activation, migration, or its own code execution. Check the status after deployment and search the code for calls to add_option() or update_option().

Will a persistent object cache help?

It may reduce the number of database queries, but it does not eliminate excessive data volume. A large set of options still occupies cache space and must be loaded and processed by PHP.

Conclusion

An autoloaded options audit starts with an inventory: find the largest records, calculate their total size, and identify the owner of each suspicious option. Do not delete unknown data blindly—create a backup first and test changes on staging.

If an option is not needed on every request, you can disable its autoloading through the WordPress API, then check the site, logs, and results with a follow-up audit. Regular checks after plugin updates can help detect unnecessary data accumulation returning.

← All WordPress materials