where为什么直接使用字符串判断时间,执行速度还快一些
CREATE_TIME字段时datetime类型,这个表30万数据,执行了0.303秒
SELECT CREATE_TIME from repay_plan
where CREATE_TIME>'2019-05-31 00:00:00'
ORDER BY REPAY_ID desc limit 10000;
而相应的cast和str_to_date 都用了0.342秒
SELECT CREATE_TIME from repay_plan
where CREATE_TIME>cast('2019-05-31 00:00:00' as datetime)
ORDER BY REPAY_ID desc limit 10000;
str_to_date function
SELECT CREATE_TIME from repay_plan
where CREATE_TIME>str_to_date('2019-05-31 00:00:00','%Y-%m-%d %H:%i:%S')
ORDER BY REPAY_ID desc limit 10000;