Oracle PL/SQL - Are NO_DATA_FOUND Exceptions bad for stored procedure performance?

后端 未结 12 1045
Happy的楠姐
Happy的楠姐 2021-02-03 23:14

I\'m writing a stored procedure that needs to have a lot of conditioning in it. With the general knowledge from C#.NET coding that exceptions can hurt performance, I\'ve always

12条回答
  •  天命终不由人
    2021-02-04 00:12

    May be beating a dead horse here, but I bench-marked the cursor for loop, and that performed about as well as the no_data_found method:

    declare
      otherVar  number;
    begin
      for i in 1 .. 5000 loop
         begin
           for foo_rec in (select NEEDED_FIELD from t where cond = 0) loop
             otherVar := foo_rec.NEEDED_FIELD;
           end loop;
           otherVar := 0;
         end;
       end loop;
    end;
    

    PL/SQL procedure successfully completed.

    Elapsed: 00:00:02.18

提交回复
热议问题