select COUNT(1) from T_Bill where EtdzTimeIndex='1106' 
T_Bill这个表很大,字段也很多,就这条sql语句统计出来大概有4万多条记录。但查询太慢了,要40秒。加索引也慢,怎么解决??

解决方案 »

  1.   


    --看看执行计划,应该是没有用到索引,试试使用强制索引
    select /*+index(T_Bill index_name)*/count(1) from T_Bill where EtdzTimeIndex='1106';
      

  2.   

      select COUNT(1) from T_Bill where EtdzTimeIndex='1106' 索引加了,把count(1) 改为主键字段试试!count(id)  
      

  3.   

    本帖最后由 roy_88 于 2011-07-07 17:57:05 编辑
      

  4.   

    本帖最后由 roy_88 于 2011-07-07 18:30:58 编辑
      

  5.   

    sfsf
      

  6.   

     EtdzTimeIndex 加索引
    用 select count(*) from tb where ..... 试试.
      

  7.   


    +1 加索引即可 。 LZ 是大概从多少数据里面查出了 4W多行啊 
      

  8.   

    create index idx_test on EtdzTimeIndex