解决方案 »

  1.   

    select   col1,col2,sum(cnt) from  table_day where querytime>=to_date('20140101','yyyymmdd') and querytime<to_date('20150101','yyyymmdd')
    group by col1,col2
      

  2.   

    分区查询只要使用分区字段就可以。
    你如果按天分区,分区列是querytime,按就用到分区查询,
    千万级这样查询即可。
    如果分区列不是querytime,要想用分区查询,查询中要用到
    分区列。
      

  3.   

    按天建的分区?这个查询跨365个分区?才千万级而已
    针对这个查询,可以建(querytime,col1,col2)的组合索引
      

  4.   

    先每个分区分组求和,再把求得结果加总:
    nsert into table1 
    select col1, col2, sum(cnt)
      from ( select querytime,col1,col2,sum(cnt) as cnt 
               from table_day 
              where querytime>=to_date('20140101') and querytime<to_date('20150101') 
              group by querytime,col1,col2 )
     group by col1, col2
      

  5.   

    另外要在col1,col2上加local索引