Chapter 3, Replication for Oracle

The following information for the “Understanding Oracle Sequence replication” section needs to be added.


Logging of Oracle Sequence information

Individual sequence changes are not logged in the Oracle database log file; however, changes to Oracle Sequences do impact (update) the Oracle sys.seq$ table. These changes do not occur with each new sequence value generated. Instead, the sys.seq$ table is updated periodically, based on sequence caching refresh activity or other system changes. The value stored in the sys.seq$ table for a sequence is the “next” value to be assigned “after” the existing cache of values has been exhausted.

For example, a newly created sequence starts with a value of 1, increments by 1, and has a cache value of 20. (These are all default values and can be customized.) The value stored in the sys.seq$ record for this new sequence is 21. This indicates that the “next” value to be used by the sequence, after the existing cache of 20 numbers is used, is 21. The record in sys.seq$ does not change until the sequence value hits 21. At that time, Oracle will cache the next 20 values for the sequence, and the sys.seq$ record will be updated to 41. It is this value (41), recorded in change to the sequences sys.seq$ record, that will be used for replication. The key point is to recognize that not every individual sequence update is recorded in the log and therefore is not available for replication.


Replicating sequence changes

When a sequence is marked for replication, changes to that sequence against sys.seq$ are captured and sent to Replication Server in the form of parameters passed to a procedure. The procedure (rs_update_sequence) must be installed at the standby site as part of system setup, as well as a function replication definition for that procedure. At the standby site, an implementation of rs_update_sequence will increment a same-named sequence until its value is equal to the value at the primary site. Scripts are provided with installation to create the rs_update_sequence stored procedure and function replication definition and are located as follows:

$SYBASE/RAX-15_0/scripts/ oracle_create_replicate_sequence_proc.sql 
$SYBASE/RAX-15_0/scripts/ oracle_create_rs_sequence_repdef.sql

Performance considerations

Compared to the performance of incrementing a sequence at the primary database, particularly where sequence values are cached, the effort to increment the same sequence at the standby site may be less efficient. The stored procedure must dynamically determine the sequence to increment and must loop internally, incrementing the sequence until the primary value has been reached. The loop is required because there is no way to assign a specific value to a sequence.

Because the name of the sequence is passed as a parameter, Oracle cannot pre-compile the procedure for efficiency. With the addition of the looping activity required to properly increment the sequence, the performance of the solution may impact some environments where a large number of highly used sequences is the norm.


Sequence replication alternatives

If the performance of sequence replication is a concern, other alternatives to replication are available that support primary and standby use of the same sequence. These alternatives are currently suggested by Oracle and others interested in providing sequence coordination between multiple sites:


Replication Agent permissions (Oracle only)

Replication Agent for Oracle uses the pds_username command to connect to Oracle. You must grant the Oracle permissions that are currently identified in the Sybase Replication Agent Primary Database Guide, including the addition of the following:


Flashback enhancements (replace this section with the following)

Oracle's new flashback feature available in Oracle version 10g is not supported in Replication Agent for Oracle. Because flashback is not supported, it requires that you disable the recycle bin:

In Oracle 10.2, to view the contents of the recycle bin:

select * from dba_recyclebin;

In Oracle 10.2, to view the current recycle bin configuration:

select value from v$parameter where name = “recyclebin”;