Processed in 1.824 second(s), 80 queries
近几天,发现服务器经常无响应,但是过一阵就好了,费了好大劲,在后台监控中看到这么个查询语句:
SELECT *,(select sum(c.carprice) from uchome_park_carinfo c,uchome_park_mycar m where c.carid=m.carid and m.uid=p.uid group by m.uid) as carprice,(select count(*) from uchome_park_mycar where uid=s.uid) as carnum FROM uchome_space s ,uchome_park_member p..(省略若干)
然后搜索程序,在park_rank.php中,36行找到如下语句,看来很是让人汗:
$query = $_SGLOBAL['db']->query("SELECT *,(select sum(c.carprice) from ".tname('park_carinfo')." c,".tname('park_mycar')." m where c.carid=m.carid and m.uid=p.uid group by m.uid) as carprice,(select count(*) from ".tname('park_mycar')." where uid=s.uid) as carnum FROM ".tname('space')." s ,".tname('park_member')." p WHERE s.uid=p.uid ".$wheresql.$ordersql." LIMIT $start,$perpage");
就这么个查询法,服务器不挂都不行...
所有的mysql进程都在等此进程,简直就是几分钟之内所有的mysql进程都处于lock状态等待其执行完毕,如果同时使用此查询的人多了,简直要老命了....
试问,能不能优化一点/能不能考虑用户服务器承受能力???
目前懒的研究优化,将其暂时注释掉去掉排行功能,省的服务器老是挂......
liuzhly 发表于 2009-12-8 13:29  |