like 是用不了任何索引的,若 A.CardNo 也有索引,建议写成
where A.CusIdl = B.cusidl and A.CardNo>='2********' and A.CardNo<'30000000'
这样的形式。

解决方案 »

  1.   

    agree with  goneaway(小伍)
      

  2.   

    要使用一个索引,有一些最基本的条件: 
        where 子句中的这个字段,必须是复合索引的第一个字段; 
        where 子句中的这个字段,不应该参与任何形式的计算
        下列操作或者操作符会显式(explicitly)地阻止使用索引:
      如果 f1 和 f2 是同一个表的两个字段,则 f1>f2, f1>=f2,  
       f1 is null, f1 is not null, f1 not in, f1!=, f1 like‘%pattern%’; 
      Not exist 
       某些情况下,f1 in 也会不用索引; 
      对于这些操作,别无办法,只有尽量避免。比如,如果发现你的 sql 中的 in 操作没有使用索引,也许可以将 in 操作改成 比较操作 + union all。