select count(status) from employee where name= 'John' and status in (0,1) and LogTime between '2005-05-10' and '2005-05-12'

解决方案 »

  1.   

    在字段:name ,LogTime,status加一个联合索引,试试
      

  2.   

    先创建status,name,LogTime列的索引修改一下where 条件的顺序试试
    select count(status) from employee where  status in (0,1) 
    and name= 'John' and LogTime>='2005-05-10' and  LogTime<'2005-05-12'
      

  3.   

    我觉得只建创建statuname,LogTime列的索引就可以了。好像status字段不同的值比较少,
    修改一下where 条件的顺序试试
    select count(status) from employee where  status in (0,1) 
     and LogTime>='2005-05-10' and  LogTime<'2005-05-12'  and and name= 'John'