Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For future, you can always re-edit your post and add content like the dump of an EXPLAIN (sql statement) as opposed to dumping into a comment.</p> <p>The query itself looks pretty direct and your indexes per the explain appear ok, but for the WP_Posts table, I might change (or just add another index) based on</p> <pre><code>( Blog_ID, Post_Type, Post_Status, ID, Post_Date ) </code></pre> <p>This way, it matches the criteria first, then the ID for optimizing the GROUP BY, and finally the Post_Date for Order By clause.</p> <p>Next, so the engine doesn't try to work by some other reference table first, have you tried adding the keyword "STRAIGHT_JOIN" to it...</p> <pre><code>SELECT STRAIGHT_JOIN wp_posts.* ... rest of query </code></pre> <p>Another alternative I would consider is to pre-query just the IDs via distinct, then join back to the WP_Posts table... I don't know if its choking on you doing a SELECT * and grouping by just the ID.</p> <pre><code>SELECT wp_posts.* FROM ( SELECT STRAIGHT_JOIN DISTINCT WP.ID from wp_posts WP INNER JOIN wp_term_relationships WPR ON WP.ID = WPR.object_id INNER JOIN wp_term_taxonomy WPTT ON WPR.term_taxonomy_id = WPTT.term_taxonomy_id INNER JOIN wp_terms WPT ON WPTT.term_id = WPT.term_id WHERE 1 = 1 AND WP.blog_id = '1' AND WP.post_type = 'post' AND WP.post_status = 'publish' AND WPTT.taxonomy = 'post_tag' AND WPT.slug IN ('rate') GROUP BY WP.ID ORDER BY WP.post_date DESC LIMIT 0, 20 ) JustIDs JOIN WP_Posts on JustIDs.ID = WP_Posts.ID </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload