Keep WordPress database leaner by removing autoloaded options from wp_options table

In WordPress a number of autoloaded options are loaded on every page, this gathers over time with deleted themes, plugins etc and can slow down a site. Typically most options that are installed in the database are permanently stored. These options which are autoloaded are loaded on very WordPress page.

To see the total size of the autoload options you can run in your sql query:

SELECT SUM(LENGTH(option_value)) as autoload_size FROM wp_options WHERE autoload='yes' 
Autoload Wp Options Totalsize
Total size in this wp_options table is 211434

The returned size is in bytes -to get to kilobytes(KB) divide by 1024 and to get to megabytes (MB) divide by a further 1024. So in this instance the load is 206.47kb and 0.201MB – a size under 1MB is ok – it is larger you will need to see who are the offenders.

Here is how to see the top 10 autoloaded options loaded onto every page from wp_options

You can run the sql command below

SELECT option_name, length(option_value) AS option_value_length FROM wp_options WHERE autoload='yes' ORDER BY option_value_length DESC LIMIT 10;
Phpmyadmin Run Wp Options Top Ten Autoload

You can adjust the DESC limit value to see more or less option values. The results are below:

Autoload Wp Options Size

So you may be able to recognize certain option names, I can see some Beaver Builder, WordPress SEO, Ubermenu and ManageWP options, if there are names you don’t recognise Google the option name, chances are you will find their origin.

In our example I know UberMenu is redundant, so lets get rid of that data. Back in your SQL tab run:

SELECT * FROM `wp_options` WHERE `autoload` = 'yes' AND `option_name` LIKE '%ubermenu%'
Find Options Table

The results are returned.

List Options Sql

You can delete by selecting all the rows or run the DELETE command from SQL instead of the SELECT command.

Delete Options Wp Table

Or run:

DELETE FROM `wp_options` WHERE `autoload` = 'yes' AND `option_name` LIKE '%ubermenu%'

Now you can follow the same process and remove any redundant options to keep your database leaner, as always with database deletion make sure you hava a back up you can switch back to if a disaster occurs.

Once you have your wp_options table under control, take a look at optimising another WordPress table, the wp_postmeta table.

Leave all Comment