【问题标题】:tuning oracle bulk collect调整 oracle 批量收集
【发布时间】:2021-05-14 22:02:53
【问题描述】:
             FORALL indx IN 1 .. l_tab.COUNT
                  
               update repair_part_bp_r5 bp
               set is_deleted='Y'           
               where 1=1
               and bp.repair_part_id = l_tab(indx)
               and bp.batch_id=p_batch_id;  

It is waiting on latch: redo writing as the update volume is 120011.

在更新过程中是否有助于将其分解成更小的块?

如果是,请帮忙提供代码示例?

还有什么想法吗?

【问题讨论】:

    标签: oracle plsql


    【解决方案1】:

    如果您在 SQL 中使用CREATE TYPE 声明了l_tab 的数据类型,那么您不需要循环,可以使用MEMBER OF 运算符:

    update repair_part_bp_r5 bp
    set   is_deleted='Y'           
    where bp.repair_part_id MEMBER OF l_tab
    and   bp.batch_id=p_batch_id;
    

    【讨论】:

      【解决方案2】:

      有像“数组更新”这样的重做工作优化(阅读 Jonathan Lewis 的“Oracle Core”中的更多详细信息)。很可能它不适用于此类 FORALL 更新。所以我建议使用MERGEusing (select column_value as repair_part_id from TABLE(ltab) s ON (bp.batch_id=p_batch_id and bp.repair_part_id =s.repair_part_id) 或干脆

      update repair_part_bp_r5 bp
      set   is_deleted='Y'           
      where bp.repair_part_id in (select * from table(l_tab))
      and   bp.batch_id=p_batch_id;
      

      nb:ltab 必须是在架构或包级别定义的集合类型。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-07-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多