If you’re running a WordPress site, chances are you’ve noticed slower page load times as your website grows. One often-overlooked culprit for lagging performance is gradual bloating of autoloaded data in your WordPress database. Optimizing this data can often significantly improve your site’s speed and user experience.
This intermediate guide outlines everything you need to know about autoloaded data, explains why it matters, and provides step-by-step recommendations to optimize it effectively. Some database administration is involved, so basic knowledge of phpMyAdmin, a visual database interface, is recommended. If that’s outside your comfort level, you may want to hire a developer who specializes in WordPress databases to help. Check out Pressable’s stragetic partners for some great options.
What is Autoloaded Data?
Autoloaded data refers to specific pieces of information in your WordPress database that are loaded automatically on every page of your site. This data is stored in the wp_options table with an “autoload” flag set to “yes.” Examples include settings for active plugins, themes, widgets, and various cached data points.
If your website were a kitchen, autoloaded data would be the things you keep next to you on a prep table. You know you’re going to need those items frequently and you don’t want to rummage around to pull them out of storage each time.
Why Does Autoloaded Data Matter?
As your website grows and you add more content and functionality, the amount of autoloaded data in your database will increase.
Your site needs autoloaded data in order to function properly. But, if left unchecked, outdated or unnecessary autoloaded data can slow query execution times, causing site-wide performance issues as it takes longer for WordPress to load all this information into memory.
Problems often occur when:
- Plugins and themes load unnecessary data sitewide instead of on specific pages.
- Unused plugins or themes leave behind residual data in the wp_options table after removal.
- Poorly coded plugins make excessive use of autoloaded data.
If your site’s autoloaded data exceeds 1MB, or worse, hits the 5MB+ range, optimization efforts are overdue.
How to Identify Excessive Autoloaded Data
Before tackling the optimization process, you’ll need to assess how much autoloaded data your site currently has. Here’s how:
Using phpMyAdmin
- Log in to phpMyAdmin through your Pressable site’s control panel.
- Select your site’s database from the left panel.
- Navigate to the SQL tab and run the following query:
SELECT SUM(LENGTH(option_value)) as autoload_size FROM wp_options WHERE autoload='yes';
- The result will give you the total size of autoloaded data, measured in bytes. Convert it to MB by dividing by 1,048,576 (1MB = 1,048,576 bytes).
If the size is above 1MB, it’s time to take action.
Longer Query for Detailed Insights
To dig deeper and identify the largest contributors to autoloaded data:
SELECT
option_name,
ROUND(LENGTH(option_value) / 1024 / 1024, 4) AS option_value_size_mb
FROM
wp_options
WHERE
autoload = 'yes'
ORDER BY
option_value_size_mb DESC
LIMIT 10;
This query lists the largest autoloaded items in descending order, helping you pinpoint the biggest offenders.
Tools for Analyzing Autoloaded Data
Aside from phpMyAdmin, some plugins and more advanced tools (like custom scripts) can make it easier to analyze and tidy your database:
- Plugins: Tools like WP Optimize or Advanced Database Cleaner offer user-friendly ways to view and manage autoloaded data without running SQL queries.
- Custom Scripts: For advanced users, scripts or WP-CLI commands can be used in conjunction with the SSH access that Pressable provides to automate data checks and cleaning.
While performing a full autoloaded data audit and cleanup falls outside our scope of support, you’re welcome to contact the customer support team to request they take a look and make some initial recommendations.
Step-by-Step Techniques to Optimize Autoloaded Data
Now that you’ve identified problematic autoloaded data, it’s time to tidy up and optimize.
Important note: Always back up your site before making changes to the database. You can also test your cleanup process on a staging clone before repeating it on your live site.
1. Remove Data Left Behind by Unused Plugins and Themes
Old plugins and themes often leave residual data in the database. Use phpMyAdmin to search for keywords related to inactive plugins. For example (note the placeholder for the plugin’s name):
SELECT * FROM wp_options WHERE autoload='yes' AND option_name LIKE '%plugin-name%';
Once identified, remove the unnecessary rows:
DELETE FROM wp_options WHERE autoload='yes' AND option_name LIKE '%plugin-name%';
2. Disable Autoload for Non-Essential Data
Some plugins and themes autoload data sitewide even when it’s not necessary. A common example is a contact form plugin loading data across all your pages when it’s only needed on the contact page.
To disable autoload for this sort of data, locate the relevant row in your database and set the “autoload” value to “no” (note the placeholder for the option_name):
UPDATE wp_options SET autoload='no' WHERE option_name='option_name';
3. Clean Up Expired Transients
Transients are temporary cached data that WordPress stores in the wp_options table. Over time, expired transients can pile up and slow things down. You can use plugins like WP Optimize or Advanced Database Cleaner, or the more specific Transient Cleaner, to safely delete expired transients.
4. Address Cron Job Leftovers
If cron jobs fail or go out of sync, they might leave unnecessary rows (_wp_session_, for example) in your database. Use this query to identify and delete such data:
DELETE FROM wp_options WHERE option_name LIKE '_wp_session_%';
5. Optimize the Database Index
For large sites with extensive autoloaded data, adding an index to the autoload column can improve query efficiency. This is moving into advanced database administration territory, so you may need to consult a WordPress developer for proper implementation.
Best Practices for Long-Term Maintenance
- Audit Your Plugins and Themes Regularly: Uninstall plugins and themes that you no longer need, and clean up residual data afterward. It’s important to understand that not all plugins are properly coded to clean up after themselves when they are uninstalled (one of many reasons to keep your plugin list as small as possible).
- Choose Lightweight Plugins: Opt for plugins that are optimized for performance and don’t autoload unnecessary data.
- Perform Routine Database Optimization: Use plugins like WP Optimize or manually clean up your database through phpMyAdmin on a regular schedule.
- Keep Backups: While Pressable does take automated hourly database backups, we strongly recommend that you always create a manual backup before making changes to your database.
Monitoring Performance After Optimization
After optimizing your autoloaded data, it’s important to test and monitor your site’s performance. Some helpful tools include:
- PageSpeed Insights, WebPageTest, or GTmetrix to assess page load speeds.
- Query Monitor to track database performance.
These tools will help you identify any lingering issues and measure the success of your optimization efforts. You can also review Pressable’s automated monthly performance reports to catch trends over time.
Get Your Site Up to Speed
Optimizing autoloaded data is an intermediate, hands-on task that does require a reasonable investment of time and effort. But it can pay dividends with a dramatic impact on your WordPress site’s speed, especially if you’re managing complex or older websites. By cleaning up excessive data, you reduce database bloat, improve query performance, and provide a faster, smoother experience for your visitors.
If you’re not sure where to start, contact the 24/7 Pressable support team to request they check your site’s overall autoloaded data size and, if any bloat is found, some guidance on the worst contributors to the dead weight.