select top 25   A.*, isNull(B.D01,'') as D01 from C1 A left join D1 B on A.C00=B.D00 where 1=1
 and C00 not in(select D00 from D2)
 and C01 like '%111%' 
 order by c01 asc
上面的能查出数据结果,时间不到1秒但同时也要查询出记录的条数,下面这个要10秒,不知哪位能优化一下,太慢了select count(*) from c1 where 1=1
and C00 not in(select D00 from D2)
 and C01 like '%111%' 

解决方案 »

  1.   

    select   count(*)   from   c1  a 
    and not exists(select 1 from d2 where doo=a.coo)
    and charindex('111',co1)>0
      

  2.   

    楼上的也不行,测试了一下,慢在  and   C01   like   '%111%' 
      

  3.   

    select   count(*)   
    from   c1   
    where   1=1
    and   C00   not   exists (select   1 from   D2 where D2.D00 = c1.C00)
    and   C01   like   '%111%'  
      

  4.   

    like '% ... %'没法使用索引。
    如果条件如此就没办法了
      

  5.   

    除非 and C01 like '111%' 满足业务逻辑需求
      

  6.   

    那像baidu之类的不是 like '%%'吗?
      

  7.   

    他们用的是全文检索,还不是like '%%'
      

  8.   

    我现在用的就是05那是不是用了like '%%'的就要建个全文索引也试过,好像没效,可能是方法错了,不知各位大哥有没详细点的教程,网上都有看