title: optimize the mysql query
body: <p>I have following mysql query which is taking long time(40s) to load the results.</p>
  
  <pre><code>SELECT SQL_CALC_FOUND_ROWS blog_posts.ID FROM blog_posts 
  LEFT JOIN blog_term_relationships AS tt0 ON (blog_posts.ID = tt0.object_id) 
  LEFT JOIN blog_term_relationships AS tt1 ON (blog_posts.ID = tt1.object_id) 
  LEFT JOIN blog_term_relationships AS tt2 ON (blog_posts.ID = tt2.object_id) 
  LEFT JOIN blog_term_relationships AS tt3 ON (blog_posts.ID = tt3.object_id) 
  WHERE 1=1  
  AND ( ( tt0.term_taxonomy_id IN (141,177) AND tt1.term_taxonomy_id IN (2389,2390) ) 
  OR ( tt2.term_taxonomy_id IN (167,1169,1715) AND tt3.term_taxonomy_id IN (2519,2520) ) ) 
  AND blog_posts.post_type = 'post' AND (blog_posts.post_status = 'publish') 
  GROUP BY blog_posts.ID ORDER BY blog_posts.post_date ASC LIMIT 0, 20
  </code></pre>
  
  <p>Is there any way to optimize this query.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>This is related to <code>wordpress</code> and this query was automatically create from the <code>wp_query</code>.</p>
  
  <p>Table structures as bellow,</p>
  
  <p><code>blog_posts</code> table:</p>
  
  <pre><code>CREATE TABLE `blog_posts` (
    `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `post_author` bigint(20) unsigned NOT NULL DEFAULT '0',
    `post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `post_content` longtext NOT NULL,
    `post_title` text NOT NULL,
    `post_excerpt` text NOT NULL,
    `post_status` varchar(20) NOT NULL DEFAULT 'publish',
    `comment_status` varchar(20) NOT NULL DEFAULT 'open',
    `ping_status` varchar(20) NOT NULL DEFAULT 'open',
    `post_password` varchar(255) NOT NULL DEFAULT '',
    `post_name` varchar(200) NOT NULL DEFAULT '',
    `to_ping` text NOT NULL,
    `pinged` text NOT NULL,
    `post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `post_content_filtered` longtext NOT NULL,
    `post_parent` bigint(20) unsigned NOT NULL DEFAULT '0',
    `guid` varchar(255) NOT NULL DEFAULT '',
    `menu_order` int(11) NOT NULL DEFAULT '0',
    `post_type` varchar(20) NOT NULL DEFAULT 'post',
    `post_mime_type` varchar(100) NOT NULL DEFAULT '',
    `comment_count` bigint(20) NOT NULL DEFAULT '0',
    PRIMARY KEY (`ID`),
    KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`),
    KEY `post_parent` (`post_parent`),
    KEY `post_author` (`post_author`),
    KEY `post_name` (`post_name`(191))
  ) ENGINE=MyISAM AUTO_INCREMENT=125636 DEFAULT CHARSET=utf8
  </code></pre>
  
  <p><code>blog_term_relationships</code> table:</p>
  
  <pre><code>CREATE TABLE `blog_term_relationships` (
    `object_id` bigint(20) unsigned NOT NULL DEFAULT '0',
    `term_taxonomy_id` bigint(20) unsigned NOT NULL DEFAULT '0',
    `term_order` int(11) NOT NULL DEFAULT '0',
    PRIMARY KEY (`object_id`,`term_taxonomy_id`),
    KEY `term_taxonomy_id` (`term_taxonomy_id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8
  </code></pre>
  
  <p>EXPLAIN QUERY:</p>
  
  <p><a href="https://i.stack.imgur.com/Zz5j2.jpg" rel="nofollow noreferrer">enter image description here</a></p>