oracle数据库触发器被加入了触发器,现在导致(DCSIBB是订单)审单速度很慢,是此条触发器影响?什么意思?

查看: 2491|回复: 5
数据库间用触发器同步数据,响应慢得要死。。。
论坛徽章:0
TRIGGER XI.TRG_INSERT_ORGN
BEFORE INSERT
ON XI.ORGN
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
if length(:new.orgn_id)=7
into cst@XJ_2_XIJ
& && &&&:new.orgn_no,
& && &&&substr(:new.orgn_id,1,5),
& && &&&:new.orgn_id,
& && &&&:new.dpt_nm,
& && &&&null,
& && &&&'1',
& && &&&'01',
& && &&&'A',
& && &&&:new.dpt_nm,
& && &&&null,
& && &&&null,
& && &&&'sys',
& && &&&sysdate,
& && &&&'sys',
& && &&&sysdate,
& && &&&null,null,null,null,null,null,null,null);
elsif length(:new.orgn_id)=5
if substr(:new.orgn_id,1,3)='<font color="#ff'
into org@XJ_2_XIJ
& && &&&:new.orgn_no,
& && &&&:new.orgn_no,
& && &&&'00',
& && &&&:new.orgn_id,
& && &&&:new.dpt_nm,
& && &&&:new.dpt_nm,
& && &&&null,
& && &&&'A',
& && &&&'20',
& && &&&null,
& && &&&null,
& && &&&null,
& && &&&null,
& && &&&null,
& && &&&null,
& && &&&:new.orgn_id,
& && &&&null,
& && &&&null,
& && &&&null,
& && &&&'1',
& && &&&null,
& && &&&null,
& && &&&null,
& && &&&null,
& && &&&null,
& && &&&null,
& && &&&'SYS',
& && &&&sysdate,
& && &&&'SYS',
& && &&&sysdate);
& && &&&insert
into cstver@XJ_2_XIJ
& && &&&:new.orgn_id,
& && &&&:new.orgn_no,
& && &&&'A',
& && &&&'20',
& && &&&:new.dpt_nm,
& && &&&null,
& && &&&'SYS',
& && &&&sysdate,
& && &&&null,
& && &&&null,
& && &&&:new.dpt_nm);
into cst@XJ_2_XIJ
& && &&&:new.orgn_no,
& && &&&'<font color="#ff',
& && &&&:new.orgn_id,
& && &&&:new.dpt_nm,
& && &&&null,
& && &&&'1',
& && &&&'01',
& && &&&'A',
& && &&&:new.dpt_nm,
& && &&&null,
& && &&&null,
& && &&&'SYS',
& && &&&sysdate,
& && &&&'SYS',
& && &&&sysdate,
& && &&&null,null,null,null,null,null,null,null);
操作也不复杂,并发也没有,更谈不上死锁。两台服务器也是在局域网内,木有网络延迟。
但是就是数据更新很慢,十几分钟了都没结果。。。。
囧啊~之前也做过插入更新删除的触发器,当时是很快的,而且也是整张表的数据全部读一遍。。。。
求高人指导!!!万分感谢!!!
论坛徽章:24
把OLD AS OLD 去掉试下&&INSERT 没有:OLD
论坛徽章:0
原帖由 ccceleven 于
08:59 发表
把OLD AS OLD 去掉试下&&INSERT 没有:OLD
还是不行啊~这应该跟old没关系吧
论坛徽章:13
试试看,不知道是否改变业务逻辑。
另外,建议把insert into ....表的字段列出来,应该会好些,因为毕竟是远程库的表
CREATE OR REPLACE TRIGGER XI.TRG_INSERT_ORGN BEFORE INSERT ON XI.ORGN REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW when lengthb(:new.orgn_id) in(5,7)
& & & & if :new.orgn_id like '001__' then --lengthb(:new.orgn_id)=5 and substr(:new.orgn_id)='001'
& & & & & & & & & & & & insert into org@XJ_2_XIJ
& & & & & & & & & & & & values( :new.orgn_no,:new.orgn_no,'00',:new.orgn_id,:new.dpt_nm,:new.dpt_nm,null,'A','20',null,null,null,null,null,null,:new.orgn_id,null,null,null,'1',null,null,null,null,null,null,'SYS',sysdate,'SYS',sysdate);
& & & & & & & & & & & & insert into cstver@XJ_2_XIJ
& & & & & & & & & & & & values( :new.orgn_id, :new.orgn_no,'A','20',:new.dpt_nm,null,'SYS',sysdate,null,null,:new.dpt_nm);
& & & & elsif :new.orgn_id like '_____' then--lengthb(:new.orgn_id)=5
& & & & & & & & & & & & insert into cst@XJ_2_XIJ
& & & & & & & & & & & & values(:new.orgn_no,'000',:new.orgn_id,:new.dpt_nm,null,'1','01','A',:new.dpt_nm,null,null,'SYS',sysdate,'SYS',sysdate,null,null,null,null,null,null,null,null);
&&else--lengthb(:new.orgn_id)=7
& & & & & & & & & & & & insert into cst@XJ_2_XIJ
& & & & & & & & & & & & values(:new.orgn_no,substr(:new.orgn_id,1,5),:new.orgn_id,:new.dpt_nm,null,'1','01','A',:new.dpt_nm,null,null,'sys',sysdate,'sys', sysdate,&&null,null,null,null,null,null,null,null);
论坛徽章:439
十几分钟是插入一行的时间?看看卡在哪个SQL上。
论坛徽章:2
如果是PLSQL/SQL ENGINE 切换的问题,可以考虑 COMPOUND TRIGGER用FORALL批量插入,下面代码供参考(需修改),可以先用一个表测试一下
CREATE OR REPLACE TRIGGER XI.TRG_INSERT_ORGN
&&FOR UPDATE ON XI.ORGN
&&COMPOUND TRIGGER
--You can adjust the thresh hold value below until reaching the optimal speed
&&threshhold CONSTANT SIMPLE_INTEGER := 1000;
&&TYPE cst_aat IS TABLE OF cst@XJ_2_XIJ%ROWTYPE INDEX BY SIMPLE_INTEGER;
&&csts&&cst_
&&TYPE org_aat IS TABLE OF org@XJ_2_XIJ%ROWTYPE INDEX BY SIMPLE_INTEGER;
&&orgs&&org_
&&... --define associative arrays for all remote tables you gonna perform DML on
& && &idx_csts& && & SIMPLE_INTEGER := 0;
& && &idx_orgs& && & SIMPLE_INTEGER := 0;
& & ... --define idxs variables for all remote tables
&&PROCEDURE flush_array_cst IS
& & n1 CONSTANT SIMPLE_INTEGER := csts.count();
& & FORALL j IN 1..n1
& && &INSERT INTO cst@XJ_2_XIJ
& && &VALUES csts(j);& &&&
& & csts.DELETE();
& & idx_csts := 0;
&&END flush_array_
&&PROCEDURE flush_array_org IS
& & n2 CONSTANT SIMPLE_INTEGER := orgs.count();
& & FORALL j IN 1..n2
& && &INSERT INTO org@XJ_2_XIJ
& && &VALUES orgs(j);& &&&
& & orgs.DELETE();
& & idx_orgs := 0;
&&END flush_array_
&&...--define procedures for all remote tables
&&BEFORE EACH ROW IS
&&IF LENGTH(:NEW.orgn_id)=7
& & idx_csts := idx_csts + 1;
& & --chagne below 'colx' to the actaul column names of the remote site tables
& && &&&csts(idx).col1 := :new.orgn_
& && &&&csts(idx).col2 := substr(:NEW.orgn_id,1,5);
& && &&&csts(idx).col3 := :NEW.orgn_
& && &&&csts(idx).col4 := :NEW.dpt_
& && &&&csts(idx).col5 := NULL;
& && &&&csts(idx).col6 := '1';
& && &&&csts(idx).col7 := '01';
& && &&&csts(idx).col8 := 'A';
& && &&&csts(idx).col9 := :NEW.dpt_
& && &&&csts(idx).col10 :=NULL;
& && &&&csts(idx).col11 :=NULL;
& && &&&csts(idx).col12 :='sys';
& && &&&csts(idx).col13 :=SYSDATE;
& && &&&csts(idx).col14 :='sys';
& && &&&csts(idx).col15 :=SYSDATE;
& & ELSIF LENGTH(:NEW.orgn_id)=5
& && &IF substr(:NEW.orgn_id,1,3)='001'
& && &&&THEN
& && & idx_orgs := idx_orgs + 1;
& && &&&--chagne below 'colx' to the actaul column names of the remote site tables
& && &&&orgs(idx).col1 := :NEW.orgn_
& && &&&orgs(idx).col2 := :NEW.orgn_
& && &&&orgs(idx).col3 := '00';
& && &&&orgs(idx).col4 := :NEW.orgn_
& && &&&orgs(idx).col5 := :NEW.dpt_
& && &&&orgs(idx).col6 := :NEW.dpt_
& && &&&orgs(idx).col7 := NULL;
& && &&&orgs(idx).col8 := 'A';
& && &&&orgs(idx).col9 := '20';
& && &&&...
& && &&&ELSE
& && &...--other rules here
& && &END IF;
& & END IF;
& & IF idx_csts &= threshhold THEN
& && &flush_array_cst();
& & END IF;
& & IF idx_orgs &= threshhold THEN
& && &flush_array_org();
& & END IF;
& & ...--other threshhold checks here
&&END BEFORE EACH ROW;
&&-- AFTER STATEMENT Section:
&&AFTER STATEMENT IS
& & flush_array_cst();
& & flush_array_org();
& & ...--flush all other arrays into table
&&END AFTER STATEMENT;
itpub.net All Right Reserved. 北京皓辰网域网络信息技术有限公司版权所有    
 北京市公安局海淀分局网监中心备案编号: 广播电视节目制作经营许可证:编号(京)字第1149号

我要回帖

更多关于 数据库的触发器 的文章

 

随机推荐