Sébastien Laframboise

Reduce autoloaded data that slows down WordPress

Reduce autoloaded data that slows down WordPress

WordPress autoload data can slow a site even if its pages are light and its hosting is responsive. The problem is often in the table wp_options : WordPress stores core, theme, and plugin settings there.

When an option is set to autoload, WordPress loads it automatically at startup. This avoids repeated queries for settings needed everywhere. However, it becomes costly if large or rarely used settings accumulate in that initial load.

The goal isn’t to delete rows at random. Instead, identify the heaviest options, confirm their purpose, then decide whether to keep them, disable their autoload, or remove them after careful verification.

What WordPress autoloads automatically

WordPress gathers autoloaded options in its options cache. The internal function wp_load_alloptions() loads and caches options whose autoload flag indicates they must be available immediately.

These options are used to store global settings. A theme may put its preferences there. A plugin may register its configuration, a serialized data array, or the result of a computation. Volume matters more than the simple number of rows.

A small option accessed on almost every page is often justified. Conversely, an option of several hundred kilobytes used only on an admin screen needlessly weighs down normal requests.

Since WordPress 6.6, the core has improved handling of new large options. When a developer lets WordPress decide autoload, a value exceeding 150 000 bytes is normally not autoloaded. This protection, however, doesn’t fix old options or those forced to autoload by code. The technical note on Options API changes also explains that historical values yes and no remain supported for compatibility.

Spotting excess autoload data

Start with Site Health

Open Tools > Site Health > Status. WordPress checks the number and total size of autoloaded options there. The check becomes critical at 800 000 bytes by default. This threshold is a diagnostic signal, not a universal limit that alone guarantees slowness or speed.

The reference in WP_Site_Health::get_test_autoloaded_options() confirms the default threshold and notes that WordPress evaluates both the number of options and their total size. Note the displayed size before making changes. That way you can verify the real effect of each change.

If the dashboard is also slow to respond, don’t conclude too quickly that autoload is the sole cause. Cron tasks, slow queries, external calls, or a plugin may also be involved. In that case, follow a full method to find the cause of a slow WordPress dashboard.

Measure with WP-CLI if you have SSH access

WP-CLI lets you get a more accurate picture without modifying the database. The command documentation wp option list provides a filter on autoload, the field size_bytes and a format that calculates the total size.

wp option list --autoload=on --format=total_bytes
wp option list --autoload=on --fields=option_name,size_bytes --format=csv

The first command gives the total volume of autoloaded options. Then export the result of the second command and sort the size_bytes column in descending order. You’ll see which keys deserve priority review.

Depending on the site’s history, the value shown in the autoload column can also be yes, on, auto or auto-on. Core treats these values as states that trigger autoload. So don’t filter your SQL analysis on the single value yes.

Identify the origin before fixing

An option’s name often provides a clue, but it’s not proof. A prefix can correspond to an active plugin, an old theme, or a tool already uninstalled. First search for the exact name in the plugin’s files or its documentation.

  • Check whether the associated plugin or theme is still active.
  • Review the plugin’s settings and note the function affected by the option.
  • Determine whether this data is used on every page or only for a one-off task.
  • Check whether the option is recreated after modification, which often indicates behavior managed by the plugin.
  • Handle one option at a time so you can attribute an issue to a single change.

Common candidates are logs stored as settings, cached API responses, data from an old page builder, and large configuration arrays. However, a key that appears useless may support a migration, a license, a scheduled task, or a hidden setting. That’s why deleting directly in phpMyAdmin is a poor first option.

A plugin that creates many large autoloaded settings also deserves a broader evaluation. Before replacing or deactivating it, see this method to spot WordPress plugins that slow down your site.

Reduce the volume without breaking the site

Prepare a rollback

Create a full backup of the database and files before changing any options. Also verify that you can restore it. This precaution is essential if a plugin depends on a poorly documented option.

Ideally work on a preproduction copy. If not, make a targeted change during a quiet period, then immediately test important pages, the contact form, login, cart, and checkout if your site sells online.

Prefer disabling autoload before deleting

If an option is necessary but rarely used, disable its autoload rather than deleting its value. WordPress will then retrieve it only when a function needs it. This approach preserves the data and reduces initial load.

For custom code, WordPress provides wp_set_option_autoload(), which changes an option’s autoload state without altering its value. The function accepts the option name and a boolean. It’s preferable to manually modifying the column because it takes the options cache into account.

wp_set_option_autoload( 'nom_de_l_option', false );

This line is an example for a developer who has already confirmed the option’s role. Do not copy a fictitious name into your site. For multiple known options, WordPress also provides a function to change their states in bulk.

Delete an option only when you have established that it is orphaned, that the associated plugin is no longer used, and that no current function reads it. Deletion becomes relevant, for example, after the complete uninstallation of a plugin that left abandoned settings.

Verify the result and prevent recurrence of the issue

After each intervention, clear applicable caches, reload Site Health, and rerun the WP-CLI measurement. Compare the total size, but also watch for errors in logs and the site’s key functions. A volume reduction is only useful if the site remains stable.

Then update the plugins and the responsible theme when a fix is available. For your development, choose autoload explicitly: enable it for small data truly required everywhere, and disable it for occasional data. The documentation for add_option() precisely recommends this distinction.

Finally, incorporate this check into your maintenance. General cleanup of revisions, transients, and unused tables remains complementary but different. You can proceed with careful cleanup of a WordPress database, while keeping in mind that autoloaded data requires analysis based on its actual usage.