Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Created November 22, 2023 12:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasgriffin/83b3d5360ea888d38066bd2a80d9a47d to your computer and use it in GitHub Desktop.
Save thomasgriffin/83b3d5360ea888d38066bd2a80d9a47d to your computer and use it in GitHub Desktop.
Helpful indexes and SQL queries to add to make WordPress run faster.
alter table `wp_usermeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_postmeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_termmeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_commentmeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_edd_customermeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_edd_licensemeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_posts` add index `ndx_id_post_status_val1` (`id`, `post_status`);
SELECT 'autoloaded data in KiB' as name, ROUND(SUM(LENGTH(option_value))/ 1024) as value FROM wp_options WHERE autoload='yes'
UNION
SELECT 'autoloaded data count', count(*) FROM wp_options WHERE autoload='yes'
UNION
(SELECT option_name, length(option_value) FROM wp_options WHERE autoload='yes' ORDER BY length(option_value) DESC LIMIT 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment