作者官方网站:http://www.wxl568.cn
首先感谢公司的环境与DB,在5,6百万的数据中秒杀数据查询to_days与curdate
to_days速度在2秒左右再高峰期,中效率会使DB数据cpu报警
curdate速度在0.几秒左右
explain select L.EMP_CODE AS empCode,
L.EQUIPMENT_NO AS equipmentNo,
L.CLOCK_TIME AS clockTime,
L.MAC_ADDRESS AS macAddress
from tt_clock_log_pd L where
to_days(L.CLOCK_TIME) = to_days(now())
and L.EQUIPMENT_NO='869159020000810'
and L.MAC_ADDRESS ='20:82:c0:1e:1a:a2';
速度比上面的快
explain select L.EMP_CODE AS empCode,
L.EQUIPMENT_NO AS equipmentNo,
L.CLOCK_TIME AS clockTime,
L.MAC_ADDRESS AS macAddress
from tt_clock_log_pd L where
L.CLOCK_TIME >= curdate()
and L.EQUIPMENT_NO='869159020000810'
and L.MAC_ADDRESS ='20:82:c0:1e:1a:a2';