FORALL i in 1 .. lst_rows.count
                    INSERT /*+append*/
                    INTO t_a
                    values lst_rows(i);这个和
FORALL i in 1..lst_col_a.count
          EXECUTE IMMEDIATE  'insert /*+append*/ into t_a(col_a,col_b) values(:V1,:V2)'
          USING   lst_col_a(i),lst_col_b(i);
性能上有没有差异的?如果用for循环的话,应该有比较明显的差异吧?

解决方案 »

  1.   

    1. 那要看你的cursor_sharing怎么设的,如果是similiar两者应该差不多.
    2. 因为forall是bulk binds,所以相对于for性能上有较大的差异
      

  2.   


    如果不是similiar的话,性能上FORALL i in 1..lst_col_a.count 
              EXECUTE IMMEDIATE  'insert /*+append*/ into t_a(col_a,col_b) values(:V1,:V2)' 
              USING   lst_col_a(i),lst_col_b(i);  就是这个好了?
    就是说forall跟动态执行对效率的提升可以叠加的了?
    我原本以为用了forall,系统会自动采用象动态执行的绑定变量的方法来提高性能的?