sql优化——模糊查询

like 和 instr的查询效率

 select   name from user where instr(id, '99')> 0;  
         等价于
 select   name from user where id like '%99%';

LIKE查询一次,就走一次全表扫描,效率非常慢

同样的效果,现在来换做INSTR函数来执行,时间上的差异很明显,INSTR在一瞬间执行完成,因为这个是查找的字段,而非走全表扫描。

猜你喜欢

转载自blog.csdn.net/farxix/article/details/80090623