|
|
2、循环删除(使用索引):
SQL> begin
2 for v in (select name from testp) loop
3 delete from testc where name = v.name;
4 end loop;
5 commit;
6 end;
7 /
PL/SQL 过程已成功完成。
已用时间: 00: 00: 08.21
我的观点:
这种情况快的原因是,相对其它情况,索引的维护减少了,主要原因是name的分布。
5、bulk collect
SQL> declare
2 type tp is table of testp.name%type;
3 v tp;
4 begin
5 select name bulk collect into v from testp;
6 forall i in 1..v.count
7 delete from testc where name = v(i);
8 commit;
9 end;
10 /
PL/SQL 过程已成功完成。
已用时间: 00: 00: 07.40
我的观点:
forall这种操作因为是Oracle做过特殊优化,减少了plsql和sql的交互,性能得到了提高,和Oracle官方提供的说法一致。 |
|