like %keyword 索引失效,使用全表扫描。但能够经过翻转函数+like前模糊查询+创建翻转函数索引=走翻转函数索引,不走全表扫描。sql
like keyword% 索引有效。函数
like %keyword% 索引失效,也没法使用反向索引。code
====================================================================索引
查询%xx的记录io
select count(c.c_ply_no) as COUNT from Policy_Data_All c, Item_Data_All i where c.c_ply_no = i.c_ply_no and i.C_LCN_NO like ’%245′ 在执行的时候,执行计划显示,消耗值,io值,cpu值均很是大,缘由是like后面前模糊查询致使索引失效,进行全表扫描 **解决方法**: 这种只有前模糊的sql能够改造以下写法 select count(c.c_ply_no) as COUNT from Policy_Data_All c, Item_Data_All i where c.c_ply_no = i.c_ply_no and reverse(i.C_LCN_NO) like reverse(‘%245′) 使用翻转函数+like前模糊查询+创建翻转函数索引=走翻转函数索引,不走全扫描。有效下降消耗值,io值,cpu值这三个指标,尤为是io值的下降。