I notice in my slow query log I have many calls like so:
SELECT post_date_gmt FROM wp_posts WHERE post_status = ‘publish’ AND post_type IN (‘post’, ‘page’, ‘attachment’, ‘qwerty’, ‘xyz’, ‘abc’) ORDER BY post_date_gmt DESC LIMIT 1;
and
SELECT post_modified_gmt FROM wp_posts WHERE post_status = ‘publish’ AND post_type IN (‘post’, ‘page’, ‘attachment’, ‘qwerty’, ‘xyz’, ‘abc’) ORDER BY post_modified_gmt DESC LIMIT 1;
I notice wp_posts does not have an index on `post_date_gmt ` nor `post_modified_gmt`
Generally speaking, would it be safe to add an index here, and worst comes to worst I can just delete it if it negatively affects anything?
[ad_2]
I added the index on a cloned database and ran the same queries.
Went from 1.5s to 0.005 (give or take). So definitely improves the speed.
Just worried on a live site, more users doing more things, unforeseen things may explode
I’m just leery touching such an important core WP table
what is calling that query? it’s the post_type IN array that gets me. that doesn’t seem like a frontend function.