0

开发:i3-2100(4 核)3.1Ghz

直播:E3-1220(4核)3.1Ghz

其他一切都几乎相同 - 4gb ram,500gb sata hds(raid 1)..

在 Dev 上运行此查询时,查询的时间show processlist;不到 1 秒,但在 Live 上它将处理查询,然后移动到“复制到 tmp 表”并骑到 300(时间)并且几乎可以说超时.

编辑:解释查询。注意 live 和 dev 上的代码和数据库是相同的。

id  select_type     table   type    possible_keys   key     key_len     ref     rows    Extra
1   SIMPLE  p   const   PRIMARY     PRIMARY     4   const   1   Using temporary; Using filesort
1   SIMPLE  pchu    ref     project_company_has_user_project_id     project_company_has_user_project_id     4   const   3958    Using where
1   SIMPLE  fqha    ref     form_question_has_answer_form_id,form_question_has...   form_question_has_answer_user_id    4   new_klarents.pchu.project_company_has_user_user_id  4   
1   SIMPLE  c   eq_ref  PRIMARY     PRIMARY     4   new_klarents.pchu.project_company_has_user_company...   1   
1   SIMPLE  u   eq_ref  PRIMARY     PRIMARY     4   new_klarents.pchu.project_company_has_user_user_id  1   

请询问更多信息,我会提供我能找到的。

我几乎得出结论,使用 ORDER BY 时需要 tmp 表。

有没有人能够看到为什么实时服务器会导致速度变慢?,当实时和开发都没有运行其他查询时,我已经运行了这些查询。

询问:

SELECT 
    pchu.project_company_has_user_id, 
    pchu.project_company_has_user_project_id, 
    pchu.project_company_has_user_user_id, 
    c.company_id, 
    c.company_hall_no, 
    c.company_type, 
    c.company_company_name, 
    c.company_stand_number, 
    c.company_locked, 
    c.company_country, 
    c.company_ready_for_page, 
    c.company_image_file_1, 
    u.user_id, 
    u.user_username, 
    p.project_id, 
    p.project_name, 
    fqha.form_question_has_answer_id, 
    fqha.form_question_has_answer_request 
FROM 
    project_company_has_user pchu
LEFT JOIN 
    company c 
    ON 
        pchu.project_company_has_user_company_id = c.company_id 
LEFT JOIN 
    user u 
    ON 
        pchu.project_company_has_user_user_id = u.user_id 
LEFT JOIN 
    project p 
    ON 
        pchu.project_company_has_user_project_id = p.project_id 
LEFT JOIN 
    form_question_has_answer f 
    ON 
        pchu.project_company_has_user_user_id = f.form_question_has_answer_user_id 
        AND 
            (f.form_question_has_answer_form_id = 174) 
WHERE 
    (p.project_id = 29 AND pchu.project_company_has_user_garbage_collection = 0) 
ORDER BY 
    company_company_name asc 
LIMIT 25
4

0 回答 0