Mysql 执行效率 REGEXP 与 % 查询效率 比较 mysql 查询 中文,模糊查询中文标题进行效率对比结果显示%执行较为快一些,EXPLAIN监控的时间是一样的

1、查询语句如下


EXPLAIN  SELECT  t.*   from    tbm_news_processing  t    where  t.title   like  '%测试%'      ;
EXPLAIN  SELECT  t.*   from    tbm_news_processing  t  where  t.title   regexp  '.*测试.*'  ;


SELECT  t.*   from    tbm_news_processing  t    where  t.title   like  '%测试%'      ;
 SELECT  t.*   from    tbm_news_processing  t  where  t.title   regexp  '.*测试.*'  ;

 

2、监控耗时对比

3、开发中使用查询方案:

<if test="null != searchVo.title  and  searchVo.title !=''">
    and p.title   REGEXP CONCAT('.*',#{searchVo.title},'.*')
</if>

改造为:

<if test="null != searchVo.title  and  searchVo.title !=''">
    and p.title    Like CONCAT('%',#{searchVo.title},'%')
</if>

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

苦思冥想行则将至

穷,有钱的大爷上个两分钱吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值