oracle PLSQL 多结果集嵌套循环处理优化

 

 oracle多结果集嵌套循环处理优化

--性能差
begin
 for a in (select id,name,sex,idcard from people) loop
    for b in (select id,name,sex,idcard from english) loop
       if a.idcard = b.idcard then
       --do something
       end if;
    end loop;
 end loop;
end;

--性能优:将多表合并成一个结果集,避免嵌套循环
begin
 for a in (select p.id,p.name,p.sex,p.idcard from people p,english e where p.idcard = e.idcard) loop
       --do something
 end loop;
end;

 

posted @ 2018-04-26 23:22  N神3  阅读(498)  评论(0编辑  收藏  举报