ITPub博客

首页 > 大数据 > 数据挖掘 > 一例数据仓库执行update引起CPU占用超过90%问题

一例数据仓库执行update引起CPU占用超过90%问题

原创 数据挖掘 作者:oxoxooxx 时间:2010-12-08 16:56:49 0 删除 编辑

[Icefeish@#][24 /etl1_home/kft/Icefeish]$db2 "select count(*) from DM.TM_STU_INFO with ur "
1
-----------
1170280
1 record(s) selected.

[Icefeish@#][25 /etl1_home/kft/Icefeish]$db2 "select count(*) from ref.tr_nbrseg with ur "
1
-----------
271251
1 record(s) selected.

CMD="update DM.TM_STU_INFO a SET BRND_CD=(select BRND_CD from ref.tr_nbrseg b where a.STUDENT_NBR between b.BEGIN_NBR and b.END_NBR fetch first 1 rows only )"
EXEDB2_CMD

--上面的语句导致CPU占用基本达到90%,此时执行select一个5条记录的表都差不多1分钟.

解决方法:
方法一.export/load
1.
export to TM_STU_INFO.txt of del select
A.SCHOOL_CD,
A.SCHOOL_NAM,
A.STUDENT_NBR,
A.STUDENT_NAM,
A.SEX,
B.BRND_CD,
A.ACADEMY,
A.CLASS,
A.ADDRESS,
A.ID,
A.PROFILE,
A.ROLLIN,
A.DUTY,
A.MAIL_ADDR
from DM.TM_STU_INFO A left outer join ods.to_usr B
on A.STUDENT_NBR =B.USR_NBR
with ur ;
2.
db2 "load client from /etl1_home/kft/Icefeish/TM_STU_INFO.txt of del insert into dm.TM_STU_INFO nonrecoverable"

方法二.利用session表中转
1.
db2 -tv +p<insert into session.TM_STU_INFO
select
A.SCHOOL_CD,
A.SCHOOL_NAM,
A.STUDENT_NBR,
A.STUDENT_NAM,
A.SEX,
B.BRND_CD,
A.ACADEMY,
A.CLASS,
A.ADDRESS,
A.ID,
A.PROFILE,
A.ROLLIN,
A.DUTY,
A.MAIL_ADDR
from DM.TM_STU_INFO A left outer join ods.to_usr B
on A.STUDENT_NBR =B.USR_NBR
with ur ;
insert into DM.TM_STU_INFO select * from session.TM_STU_INFO with ur ;
EOF

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23937368/viewspace-1042791/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    178
  • 访问量
    843645