Know more about Oracle Nologging

本文详细探讨了 Oracle 数据库中 Nologging 属性的作用与限制,包括其如何影响不同类型的 INSERT 操作及如何减少日志生成。同时讨论了在不同模式下 Nologging 的行为差异,并指出了在采用此属性时可能面临的数据恢复风险。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Know more about Oracle Nologging


Know more about Oracle Nologging

The NOLOGGING clause doesn’t prevent redo on all operations, but rather only on a subset. I searched the documentation for examples of this…

http://st-doc.us.oracle.com/11/112/server.112/e16541/parallel007.htm?term=nologging+generate+redo#VLDBG1536

[NO]LOGGING Clause

The [NO]LOGGING clause applies to tables, partitions, tablespaces, and indexes. Virtually no log is generated for certain operations (such as direct-path INSERT) if the NOLOGGING clause is used. The NOLOGGING attribute is not specified at the INSERT statement level but is
instead specified when using the ALTER or CREATE statement for a table, partition, index, or tablespace.

When a table or index has NOLOGGING set, neither parallel nor serial direct-path INSERT operations generate redo logs. Processes running with the NOLOGGING option set run faster because no redo is generated. However, after a NOLOGGING operation against a table,
partition, or index, if a media failure occurs before a backup is performed, then all tables, partitions, and indexes that have been modified might be corrupted.

Direct-path INSERT operations (except for dictionary updates) never generate redo logs if the NOLOGGING clause is used. The NOLOGGING attribute does not affect undo, only redo. To be precise, NOLOGGING allows the direct-path INSERT operation to generate a negligible
amount of redo (range-invalidation redo, as opposed to full image redo).

But I did find an Ask Tom article which is more explicit about what operations generate redo despite the NOLOGGING clause:

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5280714813869

This has a nice table of operations with either No/Archive and No/Logging specified, and you can see redo is generated most of the time.

So to sum up the NOLOGGING clause only works with certain operations and we cannot expect all REDO to be completely halted.

Another item to consider is whether the Indexes on the tables were created with NOLOGGING or not… This is covered in Index generates high redo, although it is in NOLOGGING (Doc ID 1235234.1), so please reveiw that note to see if there are some indexes that can be recreated to reduce redo further.

### Oracle NOLOGGING 操作详解 #### 定义与作用 NOLOGGING 是一种用于减少日志记录的操作模式,适用于某些特定情况下的数据操作。通过设置 NOLOGGING 属性,可以显著提高大容量数据操作的速度,因为这些操作不会被完全记录到重做日志文件中[^1]。 ```sql CREATE TABLE my_table ( id NUMBER, name VARCHAR2(50) ) NOLOGGING; ``` #### 影响范围 启用 NOLOGGING 后的影响主要体现在以下几个方面: - **恢复能力**:由于减少了日志记录,如果发生介质故障,则无法通过常规方式恢复这部分未记录的日志信息。 - **备份策略**:对于设置了 NOLOGGING 的对象,在制定增量备份计划时需特别注意,确保有其他机制来保护重要数据的安全性[^2]。 #### 应用场景 NOLOGGING 特性通常应用于以下几种情形: - **一次性导入大量静态数据**:例如初始化新应用系统的初始数据集,这类数据一旦载入便不再更改。 ```sql INSERT /*+ APPEND */ INTO target_table SELECT * FROM source_table; ``` - **临时工作区管理**:处理中间计算结果或其他不需要长期保存的信息,如复杂报表生成过程中的缓存表。 ```sql CREATE GLOBAL TEMPORARY TABLE temp_results ON COMMIT DELETE ROWS NOLOGGING AS ... ``` - **优化批量更新作业**:针对那些频繁变动但又不涉及高可用性的业务逻辑实现高效能的大规模修改动作。 #### 实践建议 为了平衡性能提升和安全性之间的关系,推荐遵循如下实践指南: - 尽量只对非关键型的数据结构采用此选项; - 在实施前充分评估潜在风险,并做好相应的应急预案准备; - 结合实际环境特点灵活调整使用频率及时机选择。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值