select TO_CHAR(V_TIME,'YYYY-MM-DD') 
count(*),count(distinct ip),count(distinct c_id) from a 
where V_TIME  between ··and··· 
group  by TO_CHAR(V_TIME,'YYYY-MM-DD'); 
 
 
十万级的现在是10s多,有人帮忙,看看如何优化吗~~~~

解决方案 »

  1.   

    1、建立索引
    2、优化sql
    select trunc(V_TIME), 
    count(*),count(distinct ip),count(distinct c_id) from a 
    where V_TIME  between ··and··· 
    group  by trunc(V_TIME); 
      

  2.   

    1、V_TIME上面建一个索引试一试2、强制使用索引3、用parallel并行
      

  3.   


    1,是不是你查询的数据量太多了,占据了总量的20%以上呢,这样的话,就只能走表扫描了,table span。2,另外你的group by的时间字段最要好把to_char函数改成trunc函数,而且针对trunc()函数执行的结果建索引试试看。
      

  4.   

    不要用distinct试试,这个比较影响效率,记得有个其他的什么词可以替代
      

  5.   

    服了3楼了,来泡妞的还是干啥的?你用了2个distinct能不慢吗?