开发者

MySQL server has gone away ERROR

开发者 https://www.devze.com 2023-02-05 07:32 出处:网络
Wa开发者_如何学编程rning: mysql_query() [function.mysql-query]: MySQL server has gone away in filename.php on line 201
Wa开发者_如何学编程rning: mysql_query() [function.mysql-query]: 
MySQL server has gone away in filename.php on line 201  

query:

SELECT * FROM ta
    LEFT JOIN tb ON ta_id = tb_oid 
    LEFT JOIN tc ON ta_id = tc_oid 
    LEFT JOIN td ON ta_id = td_oid
WHERE 
    ta_time1 > 0 OR ta_time2 > 0 OR 
    tb_time1 > 0 OR tb_time2 > 0 OR 
    tc_time1 > 0 OR tc_time2 > 0 OR 
    td_time1 > 0 OR td_time2 > 0 
GROUP BY td_id 
ORDER BY  
    ta_time1 DESC, ta_time2 DESC,
    tb_time1 DESC, tb_time2 DESC,
    tc_time1 DESC, tc_time2 DESC,
    td_time1 DESC, td_time2 DESC
LIMIT 0, 40  

How can i optimise this query?


  • Set indexes on all fields, if you havn't done that already.
  • Use as small fields as possibe. E.g. if the ID's are 128 byte strings where you can use a tiny int, use the latter

By the way, if you don't know what "has gone away" means, please check the manual: http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

0

精彩评论

暂无评论...
验证码 换一张
取 消