WordPress websites need to be regularly maintained in a variety of ways to stop them from becoming compromised, bug-ridden, and of course, from getting increasingly slower and slower over time as they accumulate in size.
One of the less-talked-about ways a WordPress website can slow down is by way of autoloaded data. In our 2-part Autoload Data series, we’ll be focussing on this very important, but often neglected aspect of maintaining a WordPress website’s database.
What is autoloaded data?
For context, we should cover what the wp_options table is. The wp_options table exists in all WordPress databases and includes the vast majority of your WordPress configuration settings, such as your site URL, your upload directory, the settings for your plugins, etc.
The wp_options table includes four columns:
- option_id – this column is a unique numerical identifier for the row.
- option_name – name of the WordPress or plugin option.
- option_value – the options settings.
As you may have guessed, the column that we’ll be looking at is ‘autoload’. This column is a basic yes/no flag, and the way it works is pretty simple. If the autoload column for an option is set to ‘Yes’, then the values for that option will be automatically loaded on every single WordPress page. If it is set to ‘No’, then the options will not be loaded.
Many WordPress plugins that add their own options to the wp_options table set the autoload value to ‘Yes’, even if it’s not necessary for those settings to load on every single page of your site. Even worse, a lot of the time when those plugins are uninstalled, they don’t clean up after themselves and remove the data that they initially added to your wp_options table. This is problematic because you can install and use a plugin briefly, uninstall it, and for the rest of your website’s lifespan that extra autoload data will be loading on every page, slowing your website down.
Most recommendations will say that anything over 900KB is over the limit of how much autoloaded data you would want or need for a typical WordPress site. Anything around 2MB could use some optimisation, and 3MB+ most likely needs some old or excess data removed pretty quickly. If you’re between 150-900KB, you’re in a good place and your performance would generally be considered optimal. Having said that, we’ve seen some particularly broken WordPress sites with autoload data in excess of 100MB! Later on in this article, we will cover how to assess how much autoloaded data is on your site.
Investigating autoloaded data
Now that you’re more familiar with what autoloaded data is, let’s move on to how you can investigate it on your own site.
As always, whenever you’re delving into your database and making changes, please ensure that you take a backup before proceeding.
Calculating Your Autoload Size
There are a few different ways that you can calculate just how much autoload data you have in your wp_options table, such as via phpMyAdmin, WP-CLI, or plugins.
Option 1: phpMyAdmin
- Load up phpMyAdmin through your cPanel or Plesk account.
- Select your database on the left-hand side.
- Click the ‘SQL’ tab at the top.
- Run the following query, which will collect all the options that are set to autoload=yes, and then sum the total size of them:
SELECT SUM(LENGTH(option_value)) as autoload_size FROM wp_options WHERE autoload=’yes’;
- You will see an output total, with the size written in KiB.
There’s usually some optimisation to be done even on smaller databases, so you’ll now need to dig a bit deeper and find out what options have the most amount of data being autoloaded.
To find the options with the most autoload data, run the following query in the same place:
SELECT LENGTH(option_value),option_name FROM wp_options WHERE autoload=’yes’ ORDER BY length(option_value) DESC LIMIT 15;
This will return the top 15 rows with the most data. From here you should know both how much autoloaded data your site has, and what the largest options are.
Option 2: WP-CLI
If you’re not yet familiar with WP-CLI, you may wish to take a look at our Getting started with WP-CLI guide to get up and running with this highly valuable skillset!
WP-CLI is a great option if you would prefer to perform your investigations via the command line. It’s also handy when you don’t have phpMyAdmin, as you’re able to run any of the above SQL queries via WP-CLI. Simply run the following when you’re in your WordPress directory:
wp db query “your query here”
For example, to calculate the top 15 autoload options size, you can run the following from the command line:
wp db query “SELECT LENGTH(option_value),option_name FROM $(wp db prefix)options WHERE autoload=’yes’ ORDER BY length(option_value) DESC LIMIT 15;”
WP-CLI will use the database credentials stored in your wp-config.php file, and run the query against your database. You will get some output printed to your terminal similar to what phpMyAdmin gave you, with a table of each option_name, and the size of the option.
Alternatively, if you don’t mind taking a few minutes to install some extra software, there is a powerful WP-CLI command that can be installed called WP-CLI Doctor. This command includes many different checks, and one of them is an autoloaded data check.
wp doctor check autoload-options-size
The above command will show your total autoloaded data size.
Now that you’ve learned what autoload data is, and how to investigate how much you have of it on your WordPress website, it’s time to clear out any unwanted autoload and improve your website’s loading time!
Check out part 2 of our Autoload Data series to learn how to disable or remove autoloaded data.
As always, if you have any questions about this post or our shared hosting, VPS, reseller or dedicated server plans, simply call us on 1300 MY HOST (694 678) during business hours, or submit a ticket through our Support Portal and one of the crew will be in touch!