本帖最后由 ve2010 于 2012-05-31 21:27:18 编辑

解决方案 »

  1.   

    newvalue和modifyhistory是否建立索引。
    select crmID from modifyHistory h1 
    where newValue like '%已面谈%' and (modifyTime > '2012-05-01 00:00:00' and modifyTime < '2012-05-29 23:59:59')and ((select count(1) from modifyHistory h2 where newValue like '%已面谈%' and h2.crmID = h1.crmID and h2.modifyTime < h1.modifyTime) = 0)
      

  2.   


    newvalue和modifyhistory都没有建立索引..
      

  3.   

    创建如下索引。create index x1 on modifyHistory(modifyTime);
    create index x2 on modifyHistory(crmID,modifyTime);
      

  4.   

    select crmID 
    from modifyHistory h1 
    where newValue like '%已面谈%' 
    and modifyTime between '2012-05-01' and '2012-05-29 23:59:59'
    and not exists (
    select 1 from modifyHistory
    where newValue like '%已面谈%'
    and crmID = h1.crmID 
    and modifyTime < h1.modifyTime
    );
      

  5.   

    select crmID  
    from modifyHistory h1  
    where newValue like '%已面谈%'  
    and modifyTime between '2012-05-01' and '2012-05-29 23:59:59'
    and not exists (
    select 1 from modifyHistory
    where newValue like '%已面谈%'
    and crmID = h1.crmID  
    and modifyTime < h1.modifyTime
    );