All Collections
Getting Started
Making Website Faster
How to Clean Up Autoloaded Options in WordPress
How to Clean Up Autoloaded Options in WordPress

Discover easy steps to clean up autoloaded options in WordPress. Streamline your site for optimal performance and faster loading times.

Emmad avatar
Written by Emmad
Updated over a week ago

Table of Contents

A big autoloaded options size is one of the most prevalent causes of slow WordPress sites, especially with initial loading times. Every time a page loads in WordPress, the autoloaded settings are loaded.

Plugins, themes, and the WordPress core all set autoloaded options. They specify how WordPress sites should work and include settings such as the default URL, theme, admin user, and more.

Autoloaded options are convenient, but they can be abused. Some plugins don't require all of their choices to be autoloaded, and others don't clean up their autoloaded options when they're deactivated or removed from WordPress.

If you have an older WordPress site, the autoloaded options are likely to be much larger than they need to be. This is also prevalent with sites that have previously utilized or just tried a variety of plugins and themes.

How to Check the Autoloaded Options Size in WordPress

The WP-CLI doctor command is the simplest approach to examine the size of the autoloaded options.

Step 1: Install WP-Doctor

wp package install wp-cli/doctor-command

Here is the list of all wp-doctor commands:

wp doctor list

Step 2: To Find Autoloaded Options Size

wp doctor check autoload-options-size

Object Caching and Autoloaded

The use of an in-memory cache layer (usually Redis or Memcached) to store WordPress intermediates, such as common database queries and the WP Options autoloaded set, is known in WordPress as object caching. It usually speeds things up, but there are occasions when you enable the object and notice no difference in speed or even a slowdown.

For acceptable efficiency considerations, the server's object caching rejects "objects" larger than 900KB. If the size of the autoloaded options exceeds the threshold, WordPress will try to push an object representing all of the WP-Options that are set to autoloaded to the object caching layer. Worse, the object-caching layer would reject the object since its value was higher than the threshold. This value would then be recalculated by WordPress. The value in question is the entire site's collection of autoloaded options. As a result, rather than searching it up once every page load, WordPress looked it up twice and thus slowing down the website.

How to Clean Up Autoloaded Options Size in WordPress

When you disable autoloaded on a data row, it doesn't mean it's deleted from your database. It only means it's no longer called into each page load automatically. There are a variety of WordPress plugins available to clear the autoloaded options in WordPress, one of which is Advanced DB Cleaner.

You can also clean autoloaded options from the command line. To find out largest rows with autoloaded data:

wp db query "SELECT 'autoloaded data in KiB' as name, ROUND(SUM(LENGTH(option_value))/ 1024) as value FROM $(wp db prefix)options WHERE autoload='yes' UNION SELECT 'autoloaded data count', count(*) FROM $(wp db prefix)options WHERE autoload='yes' UNION (SELECT option_name, length(option_value) FROM $(wp db prefix)options WHERE autoload='yes' ORDER BY length(option_value) DESC LIMIT 10)"

When you're sure the data doesn't need to be autoloaded anymore, alter the autoloaded value from yes to no in the option name to clean it.

wp db query "UPDATE $(wp db prefix)options SET autoload='no' WHERE option_name='example_largest_autoloaded_row'"

Finally, you or a developer must decide which information on your site needs autoloading and which may be deactivated without affecting functionality.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?