Friday 15 April 2011

Supplemental logging for Golden Gate

I have submitted my post in another forum where discussion for supplemental logging was going on.
Here is the my reply but I am intending to write a separate blog on Golden Gate.



There are two level of supplemental logging mentioned in oracle documentation

1. Database level supplemental logging
2. Table level supplemental logging


WHY WE NEED SUPPLEMENTAL LOGGING?

One of the main reason to enable supplemental logging is to generate logs for update statement. As insert and delete involves change to whole row (either addition or deletion of complete row) and all columns change in it where as update can happen on a column of a row. Supplemental logging make sure that enough information is captured during this update that can be used by any method based on logminer technology.

Other reasons could be to capture chained rows etc.

MINIMUM LEVEL OF SUPPLEMENTAL LOGGING

Minimum level of supplemental logging that is required as per oracle documentation is

ALTER DATABASE ADD SUPPLEMENTAL LOG DATA

By default, Oracle only logs changed columns for update operations. Normally,this means that primary key columns are not logged during an update operation.However, Replicat requires the primary key columns in order to apply the update on the target system. The ADD TRANDATA command in GGSCI is used to cause Oracle to log primary key columns for all updates

For Golden gate replication minimum level of supplemental logging require is at primary key level to uniquely identify each row for replication purpose.

Golden gate command
ADD TRANDATA scott.DEPT

actually enable supplemental logging at table level on primary key and running this command in the background
SQL ALTER TABLE "SCOTT"."DEPT" ADD SUPPLEMENTAL LOG GROUP "GGS_DEPT_1668166" ("DEPT_ID") ALWAYS

I was initially not sure why we have to enable supplemental logging twice but now my understanding is that

1. From oracle 10.2 onwards minimum level of supplemental logging at database level is required before enabling supplemental logging at table level.


2. Golden gate require minimum primary key supplemental logging which is expensive if enabled at database level when only one schema or few tables are configured for replication.

Hence basic supplemental logging enable at database level and specific primary key level on table level via Golden gate.

If you enable only table level supplemental logging without database level then oracle will not capture all changes.
LogMiner is not Showing the DML Activity When Table-Level Supplemental Logging is Enabled [ID 760897.1]
 
same is the case with if you only enable database level supplemental logging then
Can I Turn On The Oracle Supplemental Log At The DB Level Only? [ID 970903.1]
It is a logical pre-requisite to enable database level supplemental logging before enabling table level supplemental logging. This is due to bug in some oracle versions. Above mentioned article shows that table level supplemental logging can be enabled without enabling at database level.


9 comments:

  1. Thanks for the clarification. Even I was having this confusion.

    Cheers !

    ReplyDelete
  2. Thanks for this. Someone has to explain this as I can't found it in any book so far.

    keep up the good work!

    ReplyDelete
  3. Thanks for clearing that up, I think this was a tricky spot for anyone who is using oracle r12 documentation. It's funny, like someone already commented here, I really found no reference to this is the books. How could that be?!

    ReplyDelete
  4. Is it essential to enable logging at both the sites in Oracle Goldengate i.e primary database and secondary database

    R.Kapil

    ReplyDelete
    Replies
    1. Yes, better to enable at both or all sides.

      -Satya
      http://satya-dba.blogspot.com/2012/10/goldengate-interview-questions-faqs.html

      Delete
  5. Really good one !!!

    ReplyDelete
  6. Thanks for the explanation, it helped.

    ReplyDelete
  7. Add trandata enables logging for only PK columns

    adding at db level with (ALL) Columns adds to all columns

    Is my understating of the concept is correct ?

    ReplyDelete