使用批量收集或常规合并更新?
我试图通过使用批量收集和正常合并来检查更新的性能。我看到当我们在匿名块中使用简单合并时,性能会更好。使用批量收集时,需要花费更多时间。
如果正常更新(合并)比批量收集快,那么为什么Oracle引入了它?我们在哪里真正看到批量收集的好处?
declare
l_start integer;
l_end integer;
begin
l_start := dbms_utility.get_time;
merge into test111 t1
using test112 t2
on (t1.col1 = t2.col3)
when matched then update
set t1.col2 = t1.col2*5;
l_end := dbms_utility.get_time;
dbms_output.put_line(l_end - l_start);
end;
Run Code Online (Sandbox Code Playgroud)
declare
type nt_test is table of test112.col3%TYPE;
nt_val nt_test := nt_test();
cursor c is select col3 from test112;
c_limit integer := 100;
l_start integer;
l_end integer;
begin
l_start := DBMS_UTILITY.get_time;
open c;
loop
fetch c
bulk collect into nt_val limit c_limit;
exit …Run Code Online (Sandbox Code Playgroud)