我要对ProductName字段进行糊涂查询
1.where ProductName like '%LM741%' ORDER BY ProductName
2.where regexp_like(ProductName,'LM741') ORDER BY ProductName
3.where instr(ProductName,'LM741')>0 ORDER BY ProductName
我看过执行计划都一样的,,但出来的结果时间相差不大,我的表中有三百W数据,查询出来大约在30秒左右,对于这种查询还有什么更好的方法,或者优化SQl ?结果集出来大约在十秒以内

解决方案 »

  1.   

    1.where ProductName like '%LM741%' ORDER BY ProductName
    2.where regexp_like(ProductName,'LM741') ORDER BY ProductName
    3.where instr(ProductName,'LM741')>0 ORDER BY ProductName
    这三种情况都是全表扫描,都用不到索引的。所以效果是一样的。
      

  2.   

    where ProductName like 'LM741%' ORDER BY ProductName 使用索引
      

  3.   

    你的sql语句之所以要花那么多时间,是因为你的返回数据太多!
    可以考虑分页