How to Optimize Autoloaded Options in WordPress for Better Performance
Overview
Autoloaded options in WordPress are stored in the database and loaded on every page request. While these options improve performance when used correctly, excessive or unnecessary autoloaded options can slow down your site, causing longer query execution times, increasing memory usage, and even affecting backend performance.
To improve site speed and reduce database bloat, follow this guide to identify and remove unnecessary autoloaded options.
Before You Begin
Before making any database modifications, it’s strongly recommended to take a backup of the database to ensure you can restore data if needed.
Step 1: Check for Autoloaded Options in Site Health
In your WordPress backend, go to Tools > Site Health. If autoloaded options are impacting performance, you may see the following warning under “Recommended improvements”:
Step 2: Identify the Largest Autoloaded Options
To find the largest autoloaded options in your WordPress database, follow these steps:
1. Copy and Modify the SQL Query
Paste the following SQL query into a text editor like Notepad or Sublime Text:
SELECT option_name, LENGTH(option_value) AS option_size FROM wp_options WHERE autoload = 'yes' ORDER BY option_size DESC LIMIT 50;
Important: The database prefix may not be wp_
on your site. You’ll need to confirm and update it accordingly.
2. Find the Database Prefix
To determine the correct database prefix, go to your site’s Staq Panel and navigate to Database > Table:
In this example, the database prefix is ol1ao_:
Update the SQL query in your text editor, replacing wp_
with your actual database prefix:
3. Run the SQL Query
Back in the Staq Panel, under Database, click Run SQL Query:
Paste the modified SQL query into the query box and click Execute:
4. Analyze the Results
The query will return the largest autoloaded options, similar to the following:
Identify unnecessary autoloaded options, such as those belonging to inactive or deleted plugins.
Step 3: Remove Unnecessary Autoloaded Options
Once you identify unnecessary autoloaded options, you can delete them safely.
1. Note Down Unnecessary Options
For example, in the results above, Beehive Pro plugin entries were found, even though the plugin is not active. These should be removed:
2. Run a SQL Query to Delete Unnecessary Autoloaded Options
Modify the queries below to match the entries you want to remove and execute them in the Run SQL Query tool.
Delete a Single Autoloaded Option
DELETE FROM ol1ao_options WHERE option_name LIKE '_transient_beehive_%';
Delete Multiple Autoloaded Options
DELETE FROM ol1ao_options WHERE option_name IN ( '_transient_beehive_29764f09266adcea77126e85f9353733', '_transient_beehive_eb95769b5da0de5dc5cd8771c080459b', 'beehive_settings' );
If successful, you should see the message “Query was successfully executed in X seconds.”
Step 4: Verify Improvements
After deleting unnecessary autoloaded options:
- Flush Redis Object Cache if enabled.
- Verify that the website functions correctly.
- Check Site Health again to confirm that “Autoloaded options could affect performance” is now under the Passed tests section.
Conclusion
By optimizing autoloaded options, you can significantly improve backend performance and reduce database load. Regularly reviewing and cleaning autoloaded options ensures your WordPress site remains fast and responsive.
Need some help?
We all do sometimes. Please reach out to our support team by dropping us a support ticket. We will respond fast.