Oracle 中like常用但是其效率不是高。
特别是使用%a%-----》全局扫描,没有利用到任何索引。
情况可以的条件尽量下使用a%------》可以利用正序的索引。
%a------》可以利用反序的索引(当然得已有反序的索引)。
使用instr函数取代like查询,可提高效率,在海量数据中效果尤其明显。
1.%a%方式:
select * from pub_yh_bm t
where instr(t.chr_bmdm,'2')>0
等份于:
select * from pub_yh_bm t
where t.chr_bmdm like '%2%'
2.%a方式:
select * from pub_yh_bm t
where instr(t.chr_bmdm,'110101')=length(t.chr_bmdm)-length('110101')+1
等份于:
select * from pub_yh_bm t
where t.chr_bmdm like '%110101'
3.a%方式:
select * from pub_yh_bm t
where instr(t.chr_bmdm,'11010101')=1
等份于:
select * from pub_yh_bm t
where t.chr_bmdm like '11010101%'
ORACLE中的支持正则表达式的函数主要有下面四个:
最后
以上就是彪壮墨镜最近收集整理的关于like效率 regexp_Oracle中like效率正则表达式浅析的全部内容,更多相关like效率内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复