Disclaimer

Sunday, 1 December 2024

gc current and gc cr - Oracle RAC

 

The terms gc current and gc cr refer to two distinct types of block-related wait events in Oracle RAC. 

They differ in their purpose, the type of block requested, and the operations involved.




1. gc current (Global Cache Current)

  • Purpose: Represents waits associated with current blocks, which are required for DML operations (e.g., INSERT, UPDATE, DELETE).
  • Definition:
    • A current block is the latest version of a data block that can be modified by a DML operation.
    • When an instance requires a current block from another node, the block must be transferred from the owning node to the requesting node over the RAC interconnect.
  • Process:
    • The master instance flushes redo changes for the block to disk.
    • A Past Image (PI) of the block is created for recovery purposes.
    • The current block is sent to the requesting instance.
  • Common Wait Events:
    • gc current block 2-way (two-node transfer)
    • gc current block 3-way (three-node transfer)

Examples of Operations Triggering gc current:

  • Updating a row in a block that resides in another instance.
  • Deleting a row where the block is held by another instance.



2. gc cr (Global Cache Consistent Read)

  • Purpose: Represents waits associated with consistent read (CR) blocks, which are required for SELECT queries or operations needing a past version of a block.
  • Definition:
    • A CR block is a reconstructed version of a data block, representing its state at a specific SCN (System Change Number) for read consistency.
    • The CR block is created using undo data if the current block has uncommitted changes or if the requesting instance needs a version of the block from the past.
  • Process:
    • If the current block resides on another node, it is fetched.
    • Undo data is applied to reconstruct the CR version.
    • The CR block is sent to the requesting instance.
  • Common Wait Events:
    • gc cr block 2-way (two-node transfer)
    • gc cr block 3-way (three-node transfer)

Examples of Operations Triggering gc cr:

  • A SELECT query fetching a block modified by another instance but not yet committed.
  • A SELECT query requiring read-consistent access to a block modified in the past.






Performance Considerations

  1. High gc current Waits:

    • Indicates contention due to frequent inter-node DML operations.
    • Can be reduced by:
      • Application segregation (split DML and SELECT operations by node).
      • Partitioning tables to localize DML activity.
      • Optimizing LGWR performance.
  2. High gc cr Waits:

    • Indicates contention due to inter-node SELECT queries or read-consistency requirements.
    • Can be reduced by:
      • Query optimization to limit block access.
      • Partitioning tables to localize SELECT activity.
      • Improving interconnect performance.

To remember it clearly:

  • CURRENT Block = UPDATE (you’re editing, making the data live and up-to-date).
  • CR Block = SELECT (you’re just viewing, like taking a snapshot, without affecting the data).


No comments:

Post a Comment

Understanding SQL Plan Baselines in Oracle Database

  Understanding SQL Plan Baselines in Oracle Database SQL Plan Baseline is the feature in Oracle started from Database 11g that helps to pre...