当前位置:   article > 正文

MYSQL每日一用:SELECT 语句中比对(between and \ like \ left)

select where left

现在有一个百万条的数据库库测试:

 

SELECT sum(length(dest_mobile) +1 - length(replace(dest_mobile,';',''))) as channel_num
from mt_sms_200804
where date_time3 BETWEEN '2008-04-15 09:00:00' and '2008-04-15 10:00:00'

SELECT sum(length(dest_mobile) +1 - length(replace(dest_mobile,';',''))) as channel_num
from mt_sms_200804
where date_time3 like '2008-04-15 09%'


SELECT sum(length(dest_mobile) +1 - length(replace(dest_mobile,';',''))) as channel_num
from mt_sms_200804
where left(date_time3,13) = '2008-04-15 09'

 

每个小时的执行时间(10,11,12,13,14,15,16) :

BETWEEN AND :  2.047 sec   2.344 sec  3.562 sec  3.063 sec  2.266 sec  3.031 sec 2.562 sec

LIKE :                  2.375 sec   2.531 sec  2.969 sec  3.375 sec  2.109 sec  2.250 sec 2.375 sec

LEFT() :               1.906 sec   1.938 sec  2.563 sec  3.813 sec  2.218 sec  2.750 sec 2.594 sec

 

(一天的数据查询时间比对)

BETWEEN AND :  5.610 sec

LIKE :                  7.328

LEFT() :   5.640

 

这种方法也只能测试第一次测试的结果,第二次,结果就可能被缓存。

 

所以大家可以讨论一下,关于测试这三中查询方式,那个最有效率?在条件一致的情况下。

 

 

 

 

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/164307?site
推荐阅读
相关标签
  

闽ICP备14008679号