First off, here is the explain result: https://tools.mariadb.org/explain_analyzer/analyze/m9ska
That’s from this query:
ELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id ) WHERE 1=1 AND (
wp_posts.post_date_gmt > ‘2016-05-30 18:42:28’
) AND (
wp_postmeta.meta_key = ‘_thumbnail_id’
AND
( mt1.meta_key = ‘_thumbnail_id’ AND CAST(mt1.meta_value AS CHAR) > ‘0’ )
) AND wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC
There are 298,000 rows in wp_posts and 2.9M in postmeta
Been slow to figure out how to optimize WordPress – first time using it and not a fan of many inefficiencies – but saw this query pop up a few times.
All feedback Appreciated
Cheers!
Ryan