ITPub博客

首页 > 数据库 > Oracle > Oracle Nologging+Append注意事项

Oracle Nologging+Append注意事项

原创 Oracle 作者:DBhanG 时间:2020-05-31 19:50:48 0 删除 编辑

查看创建的表是否为nologging  user_tables.logging字段。

   如果直接 加载的表上有索引,Oracle不会像加载数据的方式那样来处理索引的数据,但是它同样需要维护一个索引,这个成本很高,同时会生成很多的redo。

   所以当使用直接加载时,通常是针对一些数据量非常大的表。如果这些表存在索引,将会带来很大的性能影响,这时可以考虑先将索引disable或者drop掉,等加载数据后,之后在重新建立索引。 

创建索引指定nologging:

create index idx_object_id on idx_test(object_id) nologging;

 

使用insert append的缺点在于仅会向高水位线之上的块进行插入,会忽略高水位线下的空闲块,所以 append会提高高水位线。

insert append时在表上加“ 6”类型的 Exclusive锁,即排它锁 ,为表级锁 ,会阻塞表上的所有 DML语句。因此在有业务运行的上传环境下要慎重使用。

测试:

SYS@prod>insert /*+APPEND*/ into test select * from test;

在其他会话查看锁定对象情况:

SYS@prod>select object_id,session_id,locked_mode from v$locked_object;

 OBJECT_ID SESSION_ID LOCKED_MODE

---------- ---------- -----------

     88905   125   6

  有关Append的其他错误:

ORA-12938 错误
如果直接 路径加载的事务未提交或回滚,则同一个会话无法访问被修改的表(报ORA-12838: cannot read/modify an object after modifying it in parallel ),非同一个会话可以访问。 

SYS@prod>insert /*+APPEND*/ into test select * from test;

5566720 rows created.

SYS@prod>select count(*) from test;

select count(*) from test

*

ERROR at line 1:

ORA-12838: cannot read/modify an object after modifying it in parallel


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69975956/viewspace-2695349/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Oracle Nologging详解
下一篇: Oracle OMF文件管理
请登录后发表评论 登录
全部评论

注册时间:2020-05-28

  • 博文量
    59
  • 访问量
    71332