insert into table1
select col1,col2,sum(cnt) from table_day where querytime>=to_date('20140101') and querytime<to_date('20150101')
group by col1,col2
表按天建的分区
怎样优化,查询量在千万级。
我想用 分区查询 怎样用
...全文
3866打赏收藏
oracle 优化 请教
1. 存储过程中 insert into table1 select col1,col2,sum(cnt) from table_day where querytime>=to_date('20140101') and querytime<to_date('20150101') group by col1,col2 表按天建的分区 怎样优化,查询量在千万级。 我想用 分区查询 怎样用
先每个分区分组求和,再把求得结果加总:
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
select col1,col2,sum(cnt) from table_day where querytime>=to_date('20140101','yyyymmdd') and querytime<to_date('20150101','yyyymmdd')
group by col1,col2