Skip to content

Instantly share code, notes, and snippets.

@rheinardkorf
Created December 7, 2020 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rheinardkorf/35021f97d09b90ba35866e41cb36a1d4 to your computer and use it in GitHub Desktop.
Save rheinardkorf/35021f97d09b90ba35866e41cb36a1d4 to your computer and use it in GitHub Desktop.
Useful SQL queries for dealing with WordPress optimizations.
# Get a particular option entry.
SELECT * FROM wp_options WHERE option_name="<OPTION_NAME>" LIMIT 1000;
# Make sure an option to not autoloaded.
UPDATE wp_options SET autoload = 'no' WHERE option_name="<OPTION_NAME>";
# Get the size of total autoladed values.
SELECT SUM(LENGTH(option_value)) as autoload_size FROM wp_options WHERE autoload='yes';
# Get the top 10 most "expensive" autoloaded values.
SELECT option_name, length(option_value) AS option_value_length FROM wp_options WHERE autoload='yes' ORDER BY option_value_length DESC LIMIT 10;
# Get transient values.
SELECT * FROM wp_options WHERE option_name LIKE("%transient%") LIMIT 1000;
# Get the size of total transient values.
SELECT SUM(LENGTH(option_value)) as transients_size FROM wp_options WHERE option_name LIKE("%transient%") ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment