Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 优化此sql查询(慢速查询)_Mysql_Mysql Slow Query Log - Fatal编程技术网

Mysql 优化此sql查询(慢速查询)

Mysql 优化此sql查询(慢速查询),mysql,mysql-slow-query-log,Mysql,Mysql Slow Query Log,我有一个疑问: SELECT DATE( wp_posts.post_date ) post_date, wp_posts.id, wp_posts.post_title, wp_posts.post_status, wp_posts.guid, COUNT( wp_

我有一个疑问:

SELECT
            DATE(
                wp_posts.post_date
            ) post_date,
            wp_posts.id,
            wp_posts.post_title,
            wp_posts.post_status,
            wp_posts.guid,
            COUNT(
                wp_plugin_most_popular_posts.post_id
            ) as count,
            (SELECT
                COUNT(
                    wp_plugin_most_popular_posts.post_id
                )
            FROM
                wp_plugin_most_popular_posts
            WHERE wp_plugin_most_popular_posts.post_id = wp_posts.ID 

            GROUP BY
                post_id) AS view_count
        FROM
            wp_posts

        INNER JOIN wp_term_relationships rel ON wp_posts.ID = rel.object_id
        INNER JOIN wp_term_taxonomy ttax ON rel.term_taxonomy_id = ttax.term_taxonomy_id
        INNER JOIN wp_terms terms ON ttax.term_id = terms.term_id

        JOIN wp_plugin_most_popular_posts ON wp_plugin_most_popular_posts.post_id = wp_posts.id
        WHERE
            wp_posts.post_status = "publish"

            AND taxonomy = "category"

        GROUP BY
            wp_plugin_most_popular_posts.post_id
        ORDER BY
            view_count DESC,
            post_date DESC
        LIMIT 10;
并解释回报

id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1       PRIMARY ttax    ref     PRIMARY,term_id_taxonomy,taxonomy       taxonomy        98    const    28      Using where; Using temporary; Using filesort
1       PRIMARY terms   eq_ref  PRIMARY PRIMARY 8       peiraxtiri_db.ttax.term_id      1     Using index
1       PRIMARY rel     ref     PRIMARY,term_taxonomy_id        term_taxonomy_id        8     peiraxtiri_db.ttax.term_taxonomy_id      1       Using index
1       PRIMARY wp_posts        eq_ref  PRIMARY PRIMARY 8       peiraxtiri_db.rel.object_id   Using where
1       PRIMARY wp_plugin_most_popular_posts    ref     idx2    idx2    4       peiraxtiri_db.wp_posts.ID      96      Using where; Using index
2       DEPENDENT SUBQUERY      wp_plugin_most_popular_posts    ref     idx2    idx2    4     func     96      Using where; Using index
你能帮我优化一下吗?此查询现在大约需要7-9秒:
我不是mysql优化方面的专家,我不知道该怎么做…

分类字段…他所属的表是?…查看\u count和post\u date的问题是一样的如果省略依赖子查询会发生什么?