开发服务器不会挂起什么,Live服务器需要很长时间

时间:2012-05-11 13:49:04

标签: php mysql sql database

Dev:i3-2100(4core)3.1Ghz

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

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

在Dev上运行此查询时,查询在show processlist;上的时间不到1秒,但在实时它会处理查询,然后转到'复制到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表。

是否有人能够看到实时服务器导致此速度降低的原因?我已经在live和dev没有其他查询运行时运行这些查询。

查询:

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

0 个答案:

没有答案