在库 db1中
create table test(id number(10), value varchar(15));
在库db2中
create table test(id number(10), value varchar(15));
然后在db1中建立到db2的dblink,DL_db2;
然后db1中执行insert into test@DL_db2 select * from test where id = %d;
总共有几万条记录,执行了2万左右后,就会出现每条insert语句花费50-90秒左右时间;
但是每条都能执行成功,why?
create table test(id number(10), value varchar(15));
在库db2中
create table test(id number(10), value varchar(15));
然后在db1中建立到db2的dblink,DL_db2;
然后db1中执行insert into test@DL_db2 select * from test where id = %d;
总共有几万条记录,执行了2万左右后,就会出现每条insert语句花费50-90秒左右时间;
但是每条都能执行成功,why?
insert into t22 select 1 from dual union all select 2 from dual;insert /*+ append */ into t11
select * from t22;
重启了一下,现在每秒能insert 15个左右的数据,这个oracle用了5年左右,有没有什么优化措施?
2、确认网络延迟是否正常。
3、如果目标表中原来没有记录,可以考虑用copy from ..... to..... create tablename using 的办法,减少日志的生成,可以成倍的提高效率。
刚连接oracle数据库时运行insert into test@DL_db2 select * from test where id = %d速度还能接受,
运行了万条左右,每秒就只有10个左右的操作,
越往后,速度越慢,最后竟然每个insert花了50秒左右,然后查询了一下,
发现db1数据库中的这个会话进程占用了一个cpu 95.6%之多
然后db1中执行insert into test@DL_db2 select * from test where id = %d;
总共有几万条记录,执行了2万左右后,就会出现每条insert语句花费50-90秒左右时间;
但是每条都能执行成功,why?方法相当多:
1.在db2中建立到db1的dblink,DL_db1;
然后db2中执行insert into test select * from test@DL_db1 where id = %d; 2.如果目标表中原来没有记录,可以考虑用copy from ..... to..... create tablename using 的办法,减少日志的生成,可以成倍的提高效率。
给你一个方法吧用dblink将数据复制本地库的临时表
然后再对临时表做你的操作,速度就快了
14楼的方法也不可行,已经测试了
现在每秒也就5个左右insert;但是却占用了一个cpu
insert into test@DL_db2 select * from v_test where id = %d;
看看会不会快呀(瞎猜,我也没试过)