ORACLE中Like与Instr模糊查询性能大比拼
来源:互联网 发布:白鹿原为什么停播知乎 编辑:程序博客网 时间:2024/05/08 21:57
instr(title,'手册')>0 相当于 title like '%手册%'
instr(title,'手册')=1 相当于 title like '手册%'
instr(title,'手册')=0 相当于 title not like '%手册%'
t表中将近有1100万数据,很多时候,我们要进行字符串匹配,在SQL语句中,我们通常使用like来达到我们搜索的目标。但经过实际测试发现,like的效率与instr函数差别相当大。下面是一些测试结果:
SQL> set timing on
SQL> select count(*) from t where instr(title,'手册')>0;
COUNT(*)
----------
65881
Elapsed: 00:00:11.04
SQL> select count(*) from t where title like '%手册%';
COUNT(*)
----------
65881
Elapsed: 00:00:31.47
SQL> select count(*) from t where instr(title,'手册')=0;
COUNT(*)
----------
11554580
Elapsed: 00:00:11.31
SQL> select count(*) from t where title not like '%手册%';
COUNT(*)
----------
11554580
另外,我在结另外一个2亿多的表,使用8个并行,使用like查询很久都不出来结果,但使用instr,4分钟即完成查找,性能是相当的好。这些小技巧用好,工作效率提高不少。通过上面的测试说明,ORACLE内建的一些函数,是经过相当程度的优化的。
instr(title,’aaa’)>0 相当于like
instr(title,’aaa’)=0 相当于not like
特殊用法:
select id, name from users where instr('101914, 104703', id) > 0;
它等价于
select id, name from users where id = 101914 or id = 104703;
- ORACLE中Like与Instr模糊查询性能大比拼
- ORACLE中Like与Instr模糊查询性能大比拼
- Oracle中Like与Instr模糊查询性能大比拼
- ORACLE中Like与Instr模糊查询性能大比拼
- ORACLE中Like与Instr模糊查询性能大比拼
- ORACLE中Like与Instr模糊查询性能大比拼
- ORACLE中Like与Instr模糊查询性能大比拼(转载)
- ORACLE中Like与Instr模糊查询性能大比拼(转载)
- 【转】ORACLE中Like与Instr性能大比拼
- ORACLE中Like与Instr性能大比拼
- ORACLE中like与instr性能大比拼
- ORACLE中Like与Instr性能大比拼
- ORACLE中like与instr性能大比拼
- ORACLE中Like与Instr性能大比拼(转)
- ORACLE中like与instr性能大比拼
- Oracle模糊查询之(3.2从使用函数和sql语法角度来提高模糊查询效率 二)ORACLE中Like与Instr模糊查询性能大比拼
- MySql中Like与Instr模糊查询性能比较
- Oracle模糊查询 like与instr
- 前端必读:浏览器内部工作原理
- 改写控件之《仿iOS滑动枷锁样式的登录》
- SpringMVC 过滤器Filter使用解析
- [202]Happy Number
- DateTools,可能是最好用的iOS日期工具库
- ORACLE中Like与Instr模糊查询性能大比拼
- androidの自定义控件View在Activity中使用findByViewId得到结果为null,解决方法。。
- centOS7 下安装测试mariadb,SQLAlchemy第一次使用
- 交换芯片二(L2转发原理)
- Java核心技术第3章(5)
- ios中平移手势的跳动问题
- 谈谈Unicode编码,简要解释UCS、UTF、BMP、BOM等名词
- sql类型转换和精度控制
- android开发游记:位图压缩技巧与方法总结,解决加载大图内存占用过大问题