- 论坛徽章:
- 1
|
1:SELECT DataNum, EngineId, TrainNum, Kilo, Lac, Ci, LineNum, LnType,RecIndex FROM
mv_TnSs_20140923 WHERE LnType!=0 AND ServiceType=5 AND RecTime IN
(SELECT MAX(RecTime) FROM mv_TnSs_20140923 GROUP BY EngineId);
这句执行速度非常缓慢 大概要100s左右。
但是如果单独查询
2: SELECT UNIX_TIMESTAMP(MAX(RecTime)) FROM mv_TnSs_20140923 GROUP BY EngineId;
这句只需毫秒级别。
3:SELECT DataNum, EngineId, TrainNum, Kilo, Lac, Ci, LineNum, LnType,
RecIndex FROM mv_TnSs_20140923 WHERE LnType!=0 AND ServiceType=5;
这句查询也只需毫秒级别;
4:把2句结果放到1句 “IN” 中,也是毫秒级别查询出结果。
求大神解答下原因。 |
|