把or分开,因为用or时就没有用到索引!!!
declare @count1 int
declare @count2 intselect @count1=count(id) from historydata where HDChnBoBy like '%针刺毡%'select @count2=count(id) from historydata where HDChnsubject like '%针刺毡%' 
select @count1+@count2

解决方案 »

  1.   

    你的like这样查询也是没用到索引
      

  2.   

    回复人: hsj20041004(光芒) ( ) 信誉:100  2005-6-16 18:23:14  得分: 0  
     
     
       把or分开,因为用or时就没有用到索引!!!
    declare @count1 int
    declare @count2 intselect @count1=count(id) from historydata where HDChnBoBy like '%针刺毡%'select @count2=count(id) from historydata where HDChnsubject like '%针刺毡%' 
    select @count1+@count2  
     
    这个速度还慢了两秒,而且结果也不对.
      

  3.   

    你的like语句中 '%针刺毡%',这种格式是无法使用索引的. 必须是 '针刺毡%' 这种格式才能使用索引,你看是否能够根据你的业务要求,把转化为这种格式再试试