日期:2014-05-16  浏览次数:20867 次

以下来两个sql语句,哪个效率高?请指教
SELECT p.fk_uid, SUM(p.point) AS poi, r.*
FROM t_point_log AS p 
LEFT JOIN t_ord_prd_review AS r ON p.fk_uid =r.fk_uid 
WHERE p.fk_uid IN(SELECT DISTINCT(fk_uid) FROM likeku.t_ord_prd_review)
GROUP BY p.fk_uid
ORDER BY poi DESC
LIMIT 5
;


SELECT p.fk_uid, SUM(p.point) AS poi, r.*
FROM (select * from t_point_log WHERE fk_uid IN(SELECT DISTINCT(fk_uid) FROM likeku.t_ord_prd_review)) AS p 
LEFT JOIN t_ord_prd_review AS r ON p.fk_uid =r.fk_uid 
GROUP BY p.fk_uid
ORDER BY poi DESC
LIMIT 5
;

------解决方案--------------------
没细看,不过一般来说 IN(SELECT DISTINCT(fk_uid) FROM likeku.t_ord_prd_review) 的效率显然不高。