生成从2007年到2010年的所有购买行为的数据,到另张表!
insert into t_behavior_buylot
select f_username,trunc(f_optime,'dd'),t.f_lottype,t.f_expect,sum(t.f_paymoney),count(t.f_id),SYSTIMESTAMP
from t_gather_userpaylog t
where t.f_busisort =1
and t.f_expect is not null
and t.f_optime > to_date('2007-01-01','yyyy-mm-dd')
and t.f_optime < to_date('2008-01-01','yyyy-mm-dd')
group by f_username,trunc(f_optime,'dd'),t.f_lottype,t.f_expect;
一年一年运算过去 要46分钟!
后来取消掉唯一索引和关键字,再一个个月导入 全部导完花费了1个小时!
1 索引检查
2 goup by 要大内存排序,否则写磁盘
3 写大量的UNDO 大约7个G
很多时候都明白道理,做起来就忘,白白耗费一整天的时间!
本文记录了一次从2007年至2010年购买行为数据的批量迁移过程,包括SQL查询语句、遇到的问题及解决方案,如取消唯一索引以提高效率等。
575

被折叠的 条评论
为什么被折叠?



