使用的oracle10g數(shù)據(jù)庫(kù)
請(qǐng)看下面的sql語(yǔ)句,從早上11點(diǎn)執(zhí)行到晚上9點(diǎn)還沒(méi)執(zhí)行完
update chenqi_res_tp t set t.PTPID=(select t2.uuid from res_tp t2 where t.PARAM=t2.REMARK);
commit;
然后我們看看insert
insert into res_tp_end(UUID,TPNAME,USERLABEL,PTPID,MEID,EQUIPMENTID,PROFESSIONALTYPE,EDGEPOINT)
select SE_RES_TP_END.nextval,t2.tpname,t2.userlabel,t2.uuid,t2.meid,t2.equipmentid,t2.professionaltype,t1.uuid
from chenqi_res_tp t1, res_tp t2 where t1.param=t2.remark;
commit;
5-7分鐘就執(zhí)行完了
數(shù)據(jù)量大概是100w條
由此我們可以在大數(shù)據(jù)量操作時(shí)將復(fù)雜sql語(yǔ)句轉(zhuǎn)化為簡(jiǎn)單sql語(yǔ)句分次執(zhí)行,執(zhí)行完就commit,效率快很多,同時(shí)少用update,特別是多表關(guān)聯(lián)的update,將需要update的數(shù)據(jù)插入另外的表然后再插回來(lái)效率高很多倍。
posted on 2007-03-18 21:37
陳琪 閱讀(6099)
評(píng)論(1) 編輯 收藏 所屬分類(lèi):
java