5
回答
这个sql查询如何优化?
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

explain下:

EXPLAIN SELECT
        company1_.cc_id AS col_0_0_,
        company1_.cc_company_name AS col_1_0_,
        company1_.cc_logo AS col_2_0_,
        recruitmen0_.cr_id AS col_3_0_,
        recruitmen0_.cr_position_name AS col_4_0_,
        recruitmen0_.cr_post_date AS col_5_0_,
        recruitmen0_.cr_welfware AS col_6_0_,
        recruitmen0_.cr_salary_range AS col_7_0_,
        recruitmen0_.cr_city_id AS col_8_0_,
        recruitmen0_.cr_county_id AS col_9_0_,
        recruitmen0_.cr_lat AS col_10_0_,
        recruitmen0_.cr_lng AS col_11_0_,
        recruitmen0_.cr_reward AS col_12_0_,
        recruitmen0_.cr_reward_flag AS col_13_0_,
        recruitmen0_.cr_chosen AS col_14_0_ 
    FROM
        co_recruitment recruitmen0_ CROSS 
    JOIN
        co_company company1_ CROSS 
    JOIN
        co_job job2_ 
    WHERE
        recruitmen0_.cr_company_id=company1_.cc_id 
        AND recruitmen0_.cr_is_delete=0 
        AND recruitmen0_.cr_check=1
        AND recruitmen0_.cr_job_category=job2_.cj_id 
        AND job2_.cj_type=545
        AND recruitmen0_.cr_city_id=198
    ORDER BY
        recruitmen0_.cr_reward_flag DESC,
        recruitmen0_.cr_chosen DESC,
        recruitmen0_.cr_post_date DESC LIMIT 1,10
结果:

表数据只上百条,查询最快7 百多毫秒,慢则要1.9秒。已为所有连接字段或是查询字段添加索引,为何会这么慢呢?该如何优化,求大神指点一下!

<无标签>
举报
lengmianshi
发帖于9个月前 5回/257阅
顶部