update agz set fa_id=(select B from B123 where a=agz.old_fa_id);
commit;
update agz set person_id=(select ry.id from dm_gy_ry ry where ry.sfzjhm=agz.ry_sfz and ry.yxbz='Y' and rownum=1);
commit;
update agz set person_depart=(select ry.jg_id from dm_gy_ry ry where ry.id=agz.person_id);
commit;
update agz set pperson_dw=(select jg.dw_id from dm_gy_jg jg where jg.id=agz.person_depart);
commit;
update agz set shs=( select fa.fk_px_ss_chs_id from t_px_ss_fa fa where fa.c_id=agz.fa_id);
commit;
请教高手如何优化下面oracle语句,19W条数据花了几个小时
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
5条回答 默认 最新
诸相非相 2015-10-22 01:48关注通常不需要用子查询。拿第一个sql来说,调整成下面这样
update agz,B123 set fa_id=B where a=agz.old_fa_id;其他sql类似方式把子查询"解放"出来。
当然这样还不够,要确保where条件可以用上合适的索引。
还拿第一个sql来说,如果agz.old_fa_id或者B123.a上有索引的话,执行调整后的sql效率会提高。解决 无用评论 打赏 举报