<p>生成从2007年到2010年的所有购买行为的数据,到另张表!</p>
<p>insert into t_behavior_buylot<br>
select f_username,trunc(f_optime,'dd'),t.f_lottype,t.f_expect,sum(t.f_paymoney),count(t.f_id),SYSTIMESTAMP<br>
from t_gather_userpaylog t<br>
where t.f_busisort =1<br>
and t.f_expect is not null<br>
and t.f_optime > to_date('2007-01-01','yyyy-mm-dd')<br>
and t.f_optime < to_date('2008-01-01','yyyy-mm-dd')<br>
group by f_username,trunc(f_optime,'dd'),t.f_lottype,t.f_expect;</p>
<p>一年一年运算过去 要46分钟!</p>
<p>后来取消掉唯一索引和关键字,再一个个月导入 全部导完花费了1个小时!</p>
<p>1 索引检查</p>
<p>2 goup by 要大内存排序,否则写磁盘</p>
<p>3 写大量的UNDO 大约7个G</p>
<p>很多时候都明白道理,做起来就忘,白白耗费一整天的时间!</p>
<p>insert into t_behavior_buylot<br>
select f_username,trunc(f_optime,'dd'),t.f_lottype,t.f_expect,sum(t.f_paymoney),count(t.f_id),SYSTIMESTAMP<br>
from t_gather_userpaylog t<br>
where t.f_busisort =1<br>
and t.f_expect is not null<br>
and t.f_optime > to_date('2007-01-01','yyyy-mm-dd')<br>
and t.f_optime < to_date('2008-01-01','yyyy-mm-dd')<br>
group by f_username,trunc(f_optime,'dd'),t.f_lottype,t.f_expect;</p>
<p>一年一年运算过去 要46分钟!</p>
<p>后来取消掉唯一索引和关键字,再一个个月导入 全部导完花费了1个小时!</p>
<p>1 索引检查</p>
<p>2 goup by 要大内存排序,否则写磁盘</p>
<p>3 写大量的UNDO 大约7个G</p>
<p>很多时候都明白道理,做起来就忘,白白耗费一整天的时间!</p>
本文介绍了一个从2007年至2010年的购买行为数据迁移案例,通过取消唯一索引和关键字,改进数据处理方式,成功将数据迁移时间从46分钟减少至1小时。文章还分享了在数据库操作过程中遇到的问题及解决方案。
584

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



