Oracle GoldenGate Performance Best Practices PDF
Oracle GoldenGate Performance Best Practices PDF
Introduction 1
Oracle Software 2
Database Configuration 2
Source Database 2
Target Database 5
Extract Configuration 8
Replicat Configuration 11
CPU Data 22
I/O Data 23
Replicat) 23
Workload Description 33
Environment Configuration 34
Conclusion 37
This white paper describes best practices for configuring Oracle GoldenGate for the best performance,
simple manageability, and stability for Oracle databases. Some examples of performance throughput
improvements when applying the Oracle GoldenGate tuning methodology achieved in our MAA
validation are also presented. Non-Oracle databases are not covered in this paper.
Enable supplemental logging to ensure the correct data is replicated to the target database.
Configure Oracle GoldenGate Extract in integrated capture mode to take advantage of the
database LogMiner server functionality and simplify management.
Configure Oracle GoldenGate integrated Replicat processes to leverage the apply processing
functionality that is available within the Oracle database.
Configure multiple parallel Replicat processes using batched SQL for improved apply
performance.
Refer to Oracle GoldenGate on Oracle Exadata Database Machine Configuration white paper for the
initial configuration of Oracle GoldenGate, including installation, Oracle Database File System (DBFS)
configuration for shared Oracle GoldenGate files, and Oracle Real Application Clusters (Oracle RAC)
services configuration:
http://www.oracle.com/technetwork/database/features/availability/maa-wp-gg-oracledbm-128760.pdf
The latest release of Oracle GoldenGate can be downloaded from My Oracle Support, Patches and Updates.
To make use of integrated Extract, you must use an Oracle database release of 11.2.0.3 or later. The specific patch
numbers required for 11.2.0.3 are listed in My Oracle Support (MOS) Note 1557031.1. Extract in integrated capture
mode can also be used to capture changes from Oracle releases starting with 10.2.0.4 with downstream mining
using a release 11.2.0.3 or later mining database.
To make use of integrated Replicat, use an Oracle database release of 11.2.0.4 or later.
Database Configuration
This section contains the configuration best practices for the source and target databases used in an Oracle
GoldenGate replicated environment. It is assumed that the Extract and Data Pump processes are both running on
the source environment and one or more Replicat processes are running on the target database. In an active-active
bi-directional Oracle GoldenGate environment, or when the target database may be converted to a source database,
combine both target and source database configuration steps.
Source Database
The source database should be configured with the following:
Oracle GoldenGate Extract mines the Oracle redo for data that can be replicated. The database must be running in
ARCHIVELOG mode. When using Extract in integrated capture mode, the LogMiner server can seamlessly mine
redo from the log buffer, online and archive log files.
In order to ensure that the required redo information is contained in the Oracle redo logs for segments being
replicated, it is important to override any NOLOGGING operations which would prevent the required redo information
from being generated. If you are replicating the entire database, enable database force logging mode.
Check the existing force logging status by executing the following command:
If the database is currently not in force logging mode, enable force logging by executing the following commands:
There are cases when you do not want to replicate some application data that are loaded with NOLOGGING
operations. In those cases, isolate the tables and indexes into separate tablespaces and then you can enable and
disable logging according to your requirements. You must first disable database force logging mode by executing
the following commands:
It is important to test the effects of force logging mode on database performance before configuring Oracle
GoldenGate.
Oracle GoldenGate requires key column values to be logged into redo to allow the same updated or deleted rows
manipulated on the source database to be found on the target database. Add supplemental logging at the schema
level using the Oracle GoldenGate command ADD SCHEMATRANDATA.
For additional information about creating supplemental log groups, refer to Oracle GoldenGate Installing and
Configuring Oracle GoldenGate for Oracle Database at:
http://docs.oracle.com/goldengate/1212/gg-winux/GIORA.pdf
When using Extract in integrated capture mode, an area of Oracle memory called the Streams pool must be
configured in the System Global Area (SGA) of the database. If you are using Extract in classic mode (non-
integrated capture mode), the Streams pool is not necessary.
The size requirement of the Streams pool for Extract in integrated capture mode is based on two integrated capture
mode parameters:
MAX_SGA_SIZE controls the amount of shared memory used by the LogMiner server. The default value
is 1GB and, in most cases, this is adequate. This is not the same as the database initialization parameter
SGA_MAX_SIZE.
By monitoring Automatic Workload Repository (AWR) reports during peak times for a high number of
background process waits on LogMiner preparer: memory or LogMiner reader: buffer with high Avg wait
(ms) times (>5ms) and high % bg time (>25%), increasing the MAX_SGA_SIZE parameter by 25% can
Once the MAX_SGA_SIZE parameter is increased, the amount of wait time drops significantly and no
longer causes a performance slowdown.
Set the MAX_SGA_SIZE parameter using the following Extract parameter. This example sets the
MAX_SGA_SIZE parameter to 2G:
PARALLELISM controls the number of LogMiner preparer (LMP) server processes used by the
LogMiner server. The default value for Oracle Database Enterprise Edition is 2 and is adequate for most
workloads. Oracle Database Standard Edition defaults to 1 and cannot be increased. To identify when to
increase the parallelism parameter, use the Oracle Streams Performance Advisor (SPADV) and evaluate if
all LogMiner preparer (LMP) processes are nearing 100% CPU. When the parallelism parameter has been
set to 1, you are overriding the default of 2 as shown in the following example:
While the LogMiner preparer (LMP) process is peaking at 100% CPU, the processes that are next in the
chain of data movement have plenty of available bandwidth to handle more work. Both the LogMiner
builder (LMB) and the outbound capture process (CAP) show plenty of idle time (80% and 46.7%,
respectively). By increasing the capture parallelism parameter, it is possible to increase throughput and
reduce the idle times as shown in the following example:
PATH 2 RUN_ID 52 RUN_TIME 2013-MAR-21 15:50:35 CCA Y
|<C> OGG$CAP_EXT_1A 169413 169361 1 LMR 0% 86.7% 13.3% "" LMP (2) 6.7% 53.3%
140% "CPU + Wait for CPU" LMB 66.7% 0% 33.3% "CPU + Wait for CPU" CAP 0% 0% 100%
"CPU + Wait for CPU" |<Q> "STREAMSADMIN"."OGG$Q_EXT_1A" 169383 0.01 0 |<A>
OGG$EXT_1A 0.01 0.01 0 |<B> NO BOTTLENECK IDENTIFIED
The LogMiner preparer processes are now using 140% CPU (40% more than before) and extracting at a
30% higher rate (169,361 messages per second versus 129,851).
For example, using the default values for the MAX_SGA_SIZE and PARALLELISM parameters:
STREAMS_POOL_SIZE = 2560M
The UTL_SPADV PL/SQL package provides subprograms to collect and analyze statistics for the LogMiner server
processes. The statistics help identify any current areas of contention such as CPU or I/O. To install the
UTL_SPADV package, as the Oracle GoldenGate administrator user on the source database, run the following SQL
script:
SQL> @$ORACLE_HOME/rdbms/admin/utlspadv.sql
Later in this white paper, there is an example using the UTL_SPADV package to monitor the LogMiner server
performance in real time. For additional information on the UTL_SPADV package, refer to Oracle Database PL/SQL
Packages and Types Reference at the following URL:
http://docs.oracle.com/cd/E16655_01/appdev.121/e17602/u_spadv.htm#BABBEFCI
For additional database configuration requirements, refer to Oracle GoldenGate Installing and Configuring Oracle
GoldenGate for Oracle Database at the following URL:
http://docs.oracle.com/goldengate/1212/gg-winux/GIORA.pdf
Target Database
The target database should be configured with the following:
Although Oracle GoldenGate does not require the target database to run in ARCHIVELOG mode, Oracle
recommends doing so for high availability and recoverability. If the target database is configured to fail over or switch
over to a source database, ARCHIVELOG mode is required. The target database should also be involved in a
backup strategy to match the recovery options on the source database. In the event of a failure on the source
environment and if an incomplete recovery is carried out, the target database also needs recovery to make sure the
replicated objects are not from a point in time ahead of the source.
When replicating bi-directionally or if the source and target database need to switch roles, force logging should be
enabled to prevent missing redo data required by Oracle GoldenGate Extract.
Refer to the previous section titled Source Database for instructions on how to enable force logging mode.
When using integrated Replicat, the Streams pool must be configured. If using non-integrated Replicat, the Streams
pool is not necessary.
The size requirement of the Streams pool for integrated Replicat is based on a single parameter, MAX_SGA_SIZE.
The MAX_SGA_SIZE parameter defaults to INFINITE which allows the Replicat process to use as much of the
Streams pool as possible. Oracle does not recommend setting the MAX_SGA_SIZE parameter. Instead, set the
STREAMS_POOL_SIZE initialization parameter using the following calculation:
For example, on a system with one integrated Replicat process, the calculation would be as follows:
STREAMS_POOL_SIZE = 1280M
If the Streams pool is not large enough for integrated Replicat, when it runs out of memory, the Replicat process
stalls with most of the apply processes becoming idle.
The Replicat process report file shows a gradual slowing down until no further entries are being logged. For
example:
The Oracle Streams Performance Advisor shows that most processes are in an idle state and the Replicat (<R>)
process is at 100% flow control, further indicating there is a problem with the Apply server processes. For example:
PATH 2 RUN_ID 209 RUN_TIME 2014-JUL-09 22:43:01 CCA Y
|<R> REP_1A 0.01 0.01 0 0% 100% |<Q> "SOESMALL"."OGGQ$REP_1A" 0.01 0.01 1 |<A>
OGG$REP_1A 0.01 0.01 0 APR 100% 0% 0% "" APC 100% 0% 0% "" APS (6) 600% 0% 0% ""
|<B> NO BOTTLENECK IDENTIFIED
Querying the V$GG_APPLY_RECEIVER view shows the out-of-memory condition. For example:
STATE
----------------------------------------------
Waiting for memory
When this situation occurs and the MAX_SGA_SIZE parameter has been configured, stop the Replicat process,
increase the MAX_SGA_SIZE parameter by 25%, then restart the Replicat. Remember to increase the
STREAMS_POOL_SIZE initialization parameter to hold the larger MAX_SGA_SIZE value.
If the MAX_SGA_SIZE parameter is not configured, stop the Replicat process and increase the
STREAMS_POOL_SIZE initialization parameter by 25%. The Streams pool parameter is dynamic, therefore, it may
be possible to change its value while the database is open and while there is unallocated memory available in the
SGA. For example:
-- First make sure there is enough free space to increase the Streams pool
SQL> SELECT CURRENT_SIZE/1024/1024 FREESPACE_MB FROM V$SGA_DYNAMIC_FREE_MEMORY;
FREESPACE_MB
------------
1536
If there is no free space in the SGA, shrink another area of memory first. Alternatively, the database can be restarted
with a new STREAMS_POOL_SIZE initialization parameter value.
Once the Streams pool has been altered, continue to monitor the Replicat process performance to ensure memory
starvation does not become an issue.
The database parameters controlling the size of the shared memory components in the System Global Area (SGA)
need to be configured similarly to the source database of the data being replicated. This ensures that no unexpected
drop in performance is seen due to incorrectly sized memory. For example, if the source database is configured with
an 11GB buffer cache, the same performance cannot be expected with the same workload using a 2GB buffer
cache.
If replicating a subset of the source database, the target SGA may be sized smaller. If there is additional database
work carried out on the target database, such as increased reporting applications, the SGA should be increased
accordingly.
For additional database configuration requirements, refer to the Oracle GoldenGate Installing and Configuring
Oracle GoldenGate for Oracle Database at the following URL:
http://docs.oracle.com/goldengate/1212/gg-winux/GIORA.pdf
Extract Configuration
Oracle recommends using Oracle GoldenGate Release 12.1.2.0 or later with the integrated capture mode Extract to
take advantage of the integration with the LogMiner server. Integrated capture enables seamless extraction of more
data types than with classic mode Extract, such as compressed data (Basic, OLTP, and Exadata Hybrid Columnar
Compression). There is no additional configuration required for Extract to read log files stored on Oracle ASM.
RMANs fast recovery area policies ensure that archive logs cannot be removed until Extract no longer needs them.
When using integrated capture, the default settings are appropriate for most environments. The only adjustment is
to set the STREAMS_POOL_SIZE initialization parameter correctly, as explained earlier in this paper.
If there are tables that require mapping or data conversions, the NOPASSTHRU parameter should be used. Tables
listed with the NOPASSTHRU parameter must be specified after the PASSTHRU parameter. Doing this increases
Data Pump performance and reduces CPU usage.
For example:
EXTRACT dpump_1a
USERID soeadmin, PASSWORD ****
RMTHOST ggdb02, MGRPORT 8901
RMTTRAIL /home/oracle/goldengate/latest/dirdat_os/aa
PASSTHRU
TABLE SOESMALL.*;
NOPASSTHRU
TABLE SOEADMIN.OPS, WHERE (OPNO < 10);
In this example, the PASSTHRU parameter instructs the Data Pump to pass through all tables belonging to the
SOESMALL schema, but the SOEADMIN.OPS table is processed normally.
A performance comparison test was carried out to show the difference in elapsed time and CPU time with Data
Pump using the PASSTHRU and NOPASSTHRU (the default) parameters. The workload was a Swingbench online
transaction processing (OLTP) type workload with approximately 10 DML statements per transaction affecting three
tables (5 inserts, 5 updates). A total of 34 trail files were generated totaling 16GB in size.
500
441
450 414
400
350 309
300
250 NOPASSTHRU
196
200 PASSTHRU
150
100
50
0
Elapsed Time (secs) CPU time (secs)
The elapsed time difference is a 6% reduction when using the PASSTHRU parameter, but the bigger gain is the
reduction in CPU time, which is 37% less. This improvement can vary depending on the amount of data being
replicated that requires conversion or mapping by the Data Pump.
When replicating across a Wide Area Network (WAN), follow these best practices:
These parameters should be set to a value of 1MB (1,048,576 bytes) or the calculated value, whichever is larger.
To determine suitable values for these parameters, execute the following steps:
a. Use the ping command to obtain the average round trip time (RTT).
For example:
% ping ggsoftware.com
For example, if the network between the source and target databases is 155 megabits per second (Mbits) and the
latency is 39ms, the calculation would be as follows:
In this example, because the result is more than 1MB, set the TCPBUFSIZE and TCPFLUSHBYTES parameters to
2,266,875.
The parameters are set in the Data Pump parameter file. For example:
The maximum socket buffer size for non-Windows systems is usually limited by default.
Ask your system administrator to increase the maximum socket buffer size on the source and target systems so that
Oracle GoldenGate can increase the buffer size configured with the TCPBUFSIZE parameter.
Oracle recommends leaving this default setting enabled so that streaming is used.
If there is no setting in the Data Pump parameter file to disable streaming (RMTHOST NOSTREAMING), the
asynchronous network streaming protocol is used.
Refer to the Oracle GoldenGate Windows and UNIX Reference Guide for more information on the RMTHOST
STREAMING parameter located at the following URL:
http://docs.oracle.com/goldengate/1212/gg-winux/GWURF.pdf
3. Use Data Pump compression if network bandwidth is constrained and when CPU headroom is available
Use Data Pump compression only if network bandwidth is insufficient. Before the Data Pump sends the trail file data
to the Collector process on the target database, data is compressed on the source. The Collector process then
uncompresses that data upon receipt and the uncompressed data is written to the target database trail files.
Refer to the Oracle GoldenGate Windows and UNIX Reference Guide for more information on RMTHOST
COMPRESSION parameter for Data Pump located at the following URL:
http://docs.oracle.com/goldengate/1212/gg-winux/GWURF.pdf
Replicat Configuration
The Oracle GoldenGate Replicat processes running on the target database are reading the trail files and applying
the data using SQL DML statements on the replicated objects. The following are recommendations to optimize
Replicat performance:
Integrated Replicat offers automatic parallelism which automatically increases or decreases the number of apply
processes based on the current workload and database performance. Management and tuning of Replicat
performance is simplified since you do not have to manually configure multiple Replicat processes to distribute the
tables between them. Integrated Replicat automatically enables the asynchronous commit feature so processing can
continue immediately after each COMMIT command is issued.
Refer to the Installing and Configuring Oracle GoldenGate for Oracle Database for additional information regarding
integrated Replicat configuration located at the following URL:
http://docs.oracle.com/goldengate/1212/gg-winux/GIORA.pdf
The Replicat process maintains checkpoints that provide a known position in the trail file for recovery and restart. By
default, this checkpoint information is stored in a checkpoint file for the Replicat process. Additionally, checkpoint
information can also be stored in a checkpoint table in the target database so that the checkpoint information is
included within the Replicat transaction itself. This provides a higher level of protection against inconsistencies
between the checkpoint file and the applied transactions. Integrated Replicat automatically records checkpoint
information within the target database so checkpoint table creation is not necessary.
When non-integrated Replicat uses a checkpoint table, it also takes advantage of the asynchronous commit feature
that was introduced in Oracle Database 10g Release 2 (10.2). This feature enables Replicat to continue processing
immediately after issuing the COMMIT command, which improves performance. If a checkpoint table is not used,
To create the checkpoint table in the target database, use the following GoldenGate Software Command Interface
(GGSCI) command:
Use a checkpoint table with all Replicat processes by modifying the GLOBALS file with the following parameter:
CHECKPOINTTABLE <checkpoint_table_owner>.<checkpoint_table>
For further details on using a checkpoint table, refer to section 9.3 of the Installing and Configuring Oracle
GoldenGate for Oracle Database located at the following URL:
http://docs.oracle.com/goldengate/1212/gg-winux/GIORA.pdf
a. Integrated Replicat
By default, integrated Replicat tries to group DML statements of the same type against the same object within each
transaction, and apply the transaction DML as a batch instead of applying each individual DML statement . Using
batches can reduce CPU and execution time of DML statements.
To increase the Replicat apply performance further, BATCHSQL can be enabled which groups multiple transactions
into fewer, larger transactions, batching the same DML types together. This is enabled by adding the BATCHSQL
parameter to the Replicat parameter file.
The following is an example from a target database AWR report, using integrated Replicat without BATCHSQL
enabled. There are 3-4 rows per execution on two of the tables. For example:
When BATCHSQL is enabled, the rows per execution increases and the elapsed time decreases. For example:
By adding the BATCHSQL parameter to the Replicat parameter file, which enables BATCHSQL, this small OLTP
workload example decreased elapsed time by approximately 31%.
b. Non-integrated Replicat
By default, non-integrated Replicat operates in normal mode, where each row change is made one row at a time.
Commits are issued based on the setting of the GROUPTRANSOPS parameter (which defaults to 1000). After
approximately 1000 SQL operations, a COMMIT command is issued. Replicat accumulates operations from source
transactions, in transaction order, and applies them as a group within one transaction on the target database. The
GROUPTRANSOPS parameter sets a minimum value rather than an absolute value to avoid dividing source
transactions. Replicat waits until it receives all operations from the last source transaction in the group before
applying the target transaction.
By enabling BATCHSQL mode, Replicat batches together SQL statements that affect the same table, operation type
(INSERT, UPDATE or DELETE), and column list and applies them together as an array operation. By using array
operations, apply rates generally increase because there is significantly less CPU utilization per row.
The following is an example of an insert-only workload with Replicat in normal mode (taken from an AWR report):
You can see that single row operations are being carried out because the value of the Rows per Exec column is
1.00.
In contrast, using the BATCHSQL parameter with a default OPSPERBATCH value of 1200:
The value of the Rows per Exec column has increased to approximately 1000 and there is a 4.8 times reduction in
elapsed time and CPU time for these inserts.
In most cases, Oracle recommends that you leave the setting of the OPSPERBATCH parameter at the default value
of 1200. To enable BATCHSQL for a Replicat, add the BATCHSQL parameter to the Replicat parameter file.
When BATCHSQL is enabled for a non-integrated Replicat, Oracle recommends regularly checking the process
report file and statistics to make sure few transactions are reverting back to normal mode (non-batched) because an
exception was encountered. When many exceptions occur, apply performance can suffer due to the rolling back of
the batched transaction and reapplying it in normal mode. To determine how many batched transactions are being
aborted, use the following GGSCI command:
Then, look at the latest information in the Replicat report file located in the dirrpt directory. For example:
BATCHSQL statistics:
Batch operations: 21322428
Batches: 21294
Batches executed: 21294
Queues: 21294
Batches in error: 8
Normal mode operations: 8397
Immediate flush operations: 0
PK collisions: 14381
UK collisions: 0
FK collisions: 0
In the preceding example, there are 8 transaction batches that encountered an exception, with 14381 primary key
collisions.
The following example Replicat report file shows the reason for the exceptions:
When these exceptions occur, they should be investigated and resolved before changing the BATCHSQL
configuration.
When using the BATCHSQL or GROUPTRANSOPS parameters, SQL operations from different transactions are
merged into larger transactions while maintaining transactional order. If the target transactions must match the
source transactions (for example, the number of DMLs per commit), then set GROUPTRANSOPS=1 which may limit
the Replicat performance for small transactions.
The maximum size of each statement batch is controlled by the BATCHSQL OPSPERBATCH parameter. The default
size of 1200 is adequate in most cases, but changing the batch size may result in performance gains. Setting the
batch size too low or too high may result in performance degradation. When changing the BATCHSQL parameter, do
so in a controlled manner so performance with the old and new settings can be accurately compared.
Further information on the BATCHSQL and GROUPTRANSOPS parameters can be found in the Reference for Oracle
GoldenGate Windows UNIX at the following URL:
Even when using integrated Replicat, there are times when configuring multiple integrated Replicat processes can
offer a performance advantage. The following main reasons to do this are when:
i. The integrated Replicat process is bottlenecked on the CPU. This most likely occurs when the process is
carrying out many data transformations.
ii. Large batch operations are being carried out against a set of tables that differs from normal OLTP
operations, such as large history or reporting tables. Distributing these objects into a separate Replicat
process can increase the apply performance.
The following is an example of a mixed workload of OLTP and large insert transactions. With integrated
Replicat the apply server processes have to wait for the large transaction to be applied before the OLTP
transactions can continue. When dividing the work between two integrated Replicat processes, the
following graph shows a 31% decrease in elapsed time needed to apply the entire workload:
NOTE: When using multiple integrated Replicat processes with GoldenGate Release 12.1.2.0, be sure to apply
Oracle GoldenGate performance patch 19261665 to enable faster reading through the trail files containing
uninterested transaction data.
When a workload is generated by multiple processes, a single non-integrated Replicat process is seldom able to
apply data at the same rate at which it was generated. The slower apply rate results in an increased latency
between the source and destination databases. In some situations, a single Replicat process, along with a suitable
BATCHSQL setting, can keep latency to an acceptable level. If after enabling BATCHSQL the Replicat latency is not
Oracle recommends to first configure a single Replicat process and monitor apply lag and performance. Adding
more Replicat processes should only be carried out when performance of a single Replicat causes unacceptable
apply latency.
Before configuring multiple integrated or non-integrated Replicat processes, it is important to identify the key
characteristics of the data being replicated:
i. Normally done during the Oracle GoldenGate testing phase before implementation in a production
environment, configure Extract to capture the schema or tables required for replication with the
TESTMAPPINGSPEED parameter. This parameter stops Extract from creating any trail files, but
allows you to see the type and volume of data captured, test the Extract configuration, and also
determine the overhead cost of mining the log files on the source database. After Extract has run long
enough to capture a suitable amount of workload, stop Extract to create an Extract report. The report
file is created in the dirrpt directory of the Oracle GoldenGate installation home. The report
includes a list of tables with the number of inserts, updates, and deletes carried out against each
table. For example:
ii. Use the Oracle GoldenGate STATS EXTRACT command to gather table statistics for a currently
running Extract process. While Extract is running, use the following script to retrieve table statistics for
the latest 15 minute period:
#!/bin/bash
The output produced includes table statistics since Extract was started and also since reset was
issued 15 minutes before printing the statistics. For example:
Output to /u01/goldengate/latest/dirdat_os/aa:
Extracting from SOESMALL.ORDERS to SOESMALL.ORDERS:
iii. Use the Oracle GoldenGate logdump utility to retrieve the table statistics from one or more trail files.
When one or more trail files have been created, use the following commands to retrieve the table
statistics:
Example output:
SOESMALL.INVENTORIES Partition 4
Total Data Bytes 781788504
Avg Bytes/Record 42
FieldComp 18614012
After Images 18614012
SOESMALL.ORDERS Partition 4
Total Data Bytes 1140800152
SOESMALL.ORDER_ITEMS Partition 4
Total Data Bytes 1439690630
Avg Bytes/Record 70
Insert 20567009
After Images 20567009
Refer to MOS Note 1301300.1 for detailed information about using the logdump utility to determine table
DML rates.
Use the total number of DML statements for each table to divide the tables among the Replicat processes.
This can be made easier using the Perl code example in Appendix B.
The number of Replicat processes to configure is determined by using an iterative process of adding
Replicat processes until the latency is an acceptable number without causing I/O contention on reading the
trail files, or without causing other database performance issues. Start with a single Replicat process and
measure how it performs. If performance is not acceptable (after using BATCHSQL, if possible), distribute
the tables among two or three Replicat processes and retest the performance. Continue this exercise until
a suitable performance level and latency time is reached.
If there are a small number of tables that contain a large percentage of DML which, after dividing into their
own Replicat processes, are still not applying the data fast enough, these tables can be further distributed
among Replicat processes using the @RANGE function.
For example, distributing a table between two Replicat processes would use the following MAP
parameters:
Replicat #1:
MAP SOESMALL.ORDER_ITEMS , TARGET soesmall.ORDER_ITEMS
FILTER (@RANGE (1, 2, ORDER_ID));
Replicat #2:
MAP SOESMALL.ORDER_ITEMS , TARGET soesmall.ORDER_ITEMS
FILTER (@RANGE (2, 2, ORDER_ID));
The preceding example shows that the table SOESMALL.ORDER_ITEMS is partitioned using the primary key
column ORDER_ID between two Replicat processes.
This is explained further in the Administrating Oracle GoldenGate for Windows and UNIX at the following URL:
http://docs.oracle.com/goldengate/1212/gg-winux/GWUAD.pdf
i. Use coordinated Replicat (for non-integrated Replicat only). Coordinated Replicat is a multithreaded
process that applies transactions in parallel instead of serially. Each thread handles all of the filtering,
mapping, conversion, SQL construction, and error handling for its assigned workload. A coordinator thread
coordinates transactions across threads to account for dependencies, and also ensures that DDL is
applied in a synchronized fashion preventing DML from occurring on the same object at the same time.
For further information on coordinated Replicat, refer to the Administrating Oracle GoldenGate for
Windows and UNIX at the following URL:
http://docs.oracle.com/goldengate/1212/gg-winux/GWUAD.pdf
ii. If not using coordinated Replicat, Oracle recommends that you avoid using the @RANGE function to divide
a table among Replicat processes if DDL is also applied to the table. It is not possible to predict if all DML
is completed before the DDL is applied. To help alleviate the DDL timeout issue, use the DDL EXCLUDE or
INCLUDE parameters to instruct the Replicat process to which tables DDL can be applied.
For further details on replicating DDL statements, refer to the Installing and Configuring Oracle GoldenGate for
Oracle Database at the following URL:
http://docs.oracle.com/goldengate/1212/gg-winux/GIORA.pdf
Refer to the Oracle GoldenGate on Exadata Database Machine Configuration white paper for details on how best to
configure DBFS for optimal performance and availability located at the following URL:
http://www.oracle.com/technetwork/database/features/availability/maa-wp-gg-oracledbm-128760.pdf
Using DBFS with Oracle Data Guard and Oracle GoldenGate provides synchronization between the source and
target databases with the external files used by Oracle GoldenGate. This is important during role transitions,
especially for automatic restart of Oracle GoldenGate processes after a failover. Refer to the Transparent Zero
Data-Loss Role Transition with Oracle Data Guard and Oracle GoldenGate white paper for the configuration of such
an environment located at the following URL:
The amount of acceptable lag time is dependent on an agreed upon Service Level Agreement (SLA) that states how
much time is allowed to pass between when the data was entered in the source database to the time it appears on
the target database. A lag time of 30+ minutes may be acceptable for offloading data for ad-hoc queries but not for a
banking application that often requires near zero latency.
When using integrated Extract or integrated Replicat, the latency can be determined from the database using the
following queries:
Lag is also reported by the Oracle GoldenGate manager process for both integrated and non-integrated Extract or
Replicat. The following manager parameters must be specified in the manager parameter file (located at
$GG_install_dir/dirprm/mgr.prm):
LAGREPORTMINUTES 5 -- Interval at which lag is checked
LAGINFOMINUTES 5 -- Threshold at which lag is reported
LAGCRITICALMINUTES 15 -- Critical threshold reporting value
The values for these parameters depend on your acceptable lag time.
If the latency is higher than what is acceptable, gather the recommended data listed in this section and follow the
performance tuning methodology described below to determine and resolve the performance bottleneck.
Parameters in use
Runtime statistics
To monitor performance of Oracle GoldenGate, set the REPORTCOUNT parameter in the GoldenGate process
parameter file to report real-time statistics:
This parameter should be set for all Extract, Data Pump, and Replicat processes to a suitable interval rate
(recommended maximum value of 15 MINUTES). The report file contains entries to show the current processing
rates. For example:
13688414 records processed as of 2014-07-28 22:17:17 (rate 114065,delta 132143)
141743251 records processed as of 2014-07-28 22:32:19 (rate 131239,delta 129957)
The Oracle GoldenGate process report files are located in the $GG_install_dir/dirrpt directory.
This example shows that a Replicat process applied 132,143 and 129,957 records in the two sample intervals,
which are fifteen minutes apart.
Both the processing rates and the lag should be continually monitored for sudden changes to Oracle GoldenGate
performance levels.
For example:
An ASH report can be created for a specific Replicat process by running the
$ORACLE_HOME/rdbms/admin/ashrpti.sql script and using the SQL module name. The generated report
can be used to further investigate why a particular Replicat process is not performing as expected.
CPU Data
Gathering CPU data with operating system tools like top is essential to see if Oracle GoldenGate processes are
bottlenecked on CPU rather than I/O or some other database process. As a general rule, if the Replicat process is
not on CPU for at least 40% of the time, then it is constrained by something else such as I/O or database processing
of the replicated SQL statements. It is important to gather CPU data that shows each thread of execution within a
process. For example, an Extract process uses multiple threads and it is important to be able to identify each thread
instead of the entire process consuming CPU.
The following example shows the result of using top without any thread-specific parameters:
top - 12:51:02 up 182 days, 20:51, 3 users, load average: 0.09, 0.14, 0.09
Cpu(s): 5.7%us, 0.9%sy, 0.0%ni, 93.4%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 99060552k total, 42003164k used, 57057388k free, 1219612k buffers
Swap: 25165816k total, 0k used, 25165816k free, 8591940k cached
The Extract process is using 148.3% CPU, so it is not possible to verify if one of the process threads is bottlenecked
on CPU. Instead, use top parameters to show process threads (top H for Linux). For example:
top - 12:51:45 up 182 days, 20:51, 3 users, load average: 0.19, 0.16, 0.10
Cpu(s): 6.5%us, 1.2%sy, 0.0%ni, 92.3%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 99060552k total, 42148560k used, 56911992k free, 1219612k buffers
Swap: 25165816k total, 0k used, 25165816k free, 8583880k cached
I/O Data
Gathering I/O data using operating system tools such as iostat or oswatcher is crucial to understanding where
the bottlenecks on I/O originate. For the source environment, you need to consider both reads from the redo log files
and concurrent reads and writes to and from the trail files by Extract and Data Pump processes. On the target
environment, the concurrent access to the trail files by Data Pump and one or more Replicat processes must be
monitored. As with normal database tuning, the database I/O should be monitored, and these results can be used
along with AWR and ASH to identify and resolve bottlenecks.
SPADV statistics are collected and analyzed using the UTL_SPADV package.
a. Grant the following privileges to a designated Oracle GoldenGate administrator database user:
b. Connect to the database with the user name that was granted permissions in Step a.
Oracle recommends that you gather statistics for a 30-60 minute time period during which you are troubleshooting
performance. It is also recommended to gather statistics during a 30-60 minute time period where performance is
good, serving as a baseline comparison.
To gather statistics every 15 seconds, run the following SQL*Plus command as the Oracle GoldenGate
administrator:
SQL> exec UTL_SPADV.START_MONITORING(interval=>15);
Run the following commands to determine if the monitoring job is currently running:
Appendix A contains a shell script example that displays SPADV statistics in real time.
o 73.3% of its time in flow control (waiting for the next process in the chain (LMP))
The following example shows the output for integrated Replicat (excerpt using an Oracle Database 12c database):
PATH 2 RUN_ID 69 RUN_TIME 2014-JUL-15 08:34:57 CCA Y
|<R> REP_1A 111937 15724041 0 0% 31.3% 50% "CPU + Wait for CPU" |<Q>
"SOESMALL"."OGGQ$REP_1A" 111636 0.01 4870 |<A> OGG$REP_1A 114395 11729 -1 APR 0%
12.5% 87.5% "CPU + Wait for CPU" APC 56.3% 0% 43.8% "CPU + Wait for CPU" APS
(12) 237.5% 0% 931.3% "CPU + Wait for CPU" |<B> OGG$REP_1A APS 1374 47804 100.%
"CPU + Wait for CPU"
The apply rate at this sample time is 114,395 messages per second by the apply process, OGG$REP_1A.
o 31.3% of its time in flow control (waiting for another process further along in the chain)
o 12.5% of its time in flow control (waiting on another process further along in the chain)
o There are twelve APS processes, therefore, 931.1% of twelve processes equates to 77.6% of
total time
A single APS process is identified as the bottleneck with 100% CPU consumption or time spent waiting for
CPU.
The integrated Replicat SPADV clearly shows there is a bottleneck on apply server processes on CPU. See the
methodology described later to learn how to resolve such bottlenecks.
To generate a text report, from SQL*Plus as the Oracle GoldenGate administrator, execute the following:
spool /tmp/spadv.txt
begin
utl_spadv.show_stats(path_stat_table=>'STREAMS$_PA_SHOW_PATH_STAT',
bgn_run_id=> 1,
end_run_id=> 9999,
show_legend=> TRUE);
end;
After the reports have been generated, Oracle recommends purging the SPADV statistics using the following
command:
SQL> exec UTL_SPADV.STOP_MONITORING(PURGE=>TRUE);
Configuration - reports definitions relevant for Oracle GoldenGate integrated Extract and integrated
Replicat.
Statistics - reports statistics for those elements of integrated capture and integrated Replicat that are
enabled.
Healthcheck is a statically generated report, so it only reflects the status at one point in time. Oracle recommends
gathering two or three healthcheck reports at several minute intervals to make sure that the components are flowing
correctly.
For instructions on downloading and for further information about using the healthcheck, refer to MOS Note
1448324.1 located at the following URL:
https://support.oracle.com/oip/faces/secure/km/DocumentDisplay.jspx?id=1448324.1&h=Y
1. Oracle log files are read by the Extract process capturing any required data for replication.
2. Extract carries out any mapping and conversion to the data and then writes it out to the trail files.
3. Data Pump reads the trail files and carries out any mapping and conversion required to the data.
4. Data Pump transfers the trail files from the source system to the target system where it is written by the
Collector process to the remote trail files.
5. Replicat reads the trail file, applies any mapping and conversions, and applies the data to the target database
using SQL statements.
The following workflow demonstrates how to determine and resolve where replication latency is introduced in Oracle
GoldenGate and, consequently, where the performance bottleneck is present. Performance tuning is an iterative
process. Once something has been changed in the environment, lag needs to be monitored and then the tuning
process repeated.
1. Where is the latency being reported first, moving from Extract to Replicat?
Move from the left to right side, using the previously recommended method to gather data to view the Oracle
GoldenGate process latency (database queries, ggserr.log, ggsci INFO *, LAG EXTRACT, or LAG
REPLICAT).
Once the left most process with lag has been found, continue to the next step.
The following example shows output from the ggserr.log file for an Extract and Data Pump process with
increasing lag:
a. If the Extract process (classic or Extract in integrated capture mode) is reaching maximum CPU (90-100%) as
shown in top, create an additional Extract process and partition the work to be extracted between them.
For example:
top - 18:22:41 up 184 days, 3:52, 4 users, load average: 1.00, 0.66, 0.37
Cpu(s): 7.8%us, 1.3%sy, 0.0%ni, 90.5%id, 0.5%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 99060552k total, 61840724k used, 37219828k free, 3399436k buffers
Swap: 25165816k total, 0k used, 25165816k free, 24251384k cached
b. If one or more of the LogMiner preparer processes are reaching maximum CPU (90-100%) and if there is
available idle time for the LogMiner builder (LMB) process, increase the Extract PARALLELISM parameter
(described earlier). This shows up in top and SPADV.
c. If there are I/O waits in the source database for log file reads (for example, if AWR shows log file sequential read
> 20ms), place the log files on a faster I/O system.
d. If there are I/O wait times on the Oracle GoldenGate trail file location, move the trail files to a higher performing
file system.
When trail files are located on non-DBFS storage, use of iostat can quickly identify the issue. For example:
Time: 12:35:00 PM
avg-cpu: %user %nice %system %iowait %steal %idle
17.03 0.00 3.47 7.83 0.00 71.68
Device: wrqm/s r/s w/s wkB/s avgrq-sz avgqu-sz await svctm %util
sda2 8361.40 0.00 445.60 38630.40 173.39 88.49 192.18 1.38 61.48
Time: 12:36:00 PM
avg-cpu: %user %nice %system %iowait %steal %idle
14.76 0.00 2.31 8.81 0.00 74.12
Device: wrqm/s r/s w/s wkB/s avgrq-sz avgqu-sz await svctm %util
sda2 18551.60 0.00 994.80 77213.60 155.23 187.03 175.34 1.01 100.00
If trail files are located on a DBFS file system, a combination of iostat and Automatic Workload Repository (AWR)
reports from the DBFS instance can similarly identify any I/O contention.
e. If using integrated Extract and if there are high background waits (>25%) in the source database AWR report for
LogMiner preparer: memory or LogMiner reader: buffer, increase the MAX_SGA_SIZE Extract parameter by 25%.
Make sure the STREAMS_POOL_SIZE initialization parameter is sized large enough. Memory sizing was discussed
earlier in this white paper.
a. If the Data Pump process is reaching maximum CPU (90-100%) as shown in top, using the PASSTHRU
parameter helps decrease CPU consumption (detailed previously in this white paper). If this does not help due to
top - 14:47:27 up 8 days, 22:47, 3 users, load average: 0.83, 0.38, 0.14
Cpu(s): 4.0%us, 0.4%sy, 0.0%ni, 95.5%id, 0.0%wa, 0.0%hi, 0.1%si, 0.0%st
Mem: 99060552k total, 61544204k used, 37516348k free, 1390584k buffers
Swap: 25165816k total, 0k used, 25165816k free, 26834216k cached
b. If there are I/O wait times on the Oracle GoldenGate trail file location, move the trail files to a higher performing
file system. This problem also shows up in Extract performance. For an example, refer to item 2d in the preceding
section.
c. If there are I/O wait times on the Oracle GoldenGate trail file location on the target database, move the trail files to
a higher performing file system. This problem also shows up in Replicat trail file reading performance (discussed
later in this white paper). For an example, refer to item 2d in the preceding section.
d. If there is a network bandwidth or high latency problem identified by operating system utilities or network
monitoring tools, consider enabling Data Pump compression as previously detailed in the section titled Data Pump
Configuration.
a. If a Replicat process is reaching maximum CPU (90-100%) as shown in top, create an additional Replicat
process and partition the work between the new process and the bottlenecked Replicat process (discussed earlier in
the section titled Replicat Configuration). If you are doing a lot of data transformations, consider moving the
transformations to the Data Pump process.
b. If there are I/O wait times on the Oracle GoldenGate trail file location, move the trail files to a higher performing
file system. This problem also shows up in Data Pump performance. If multiple Replicat processes are configured to
read the same trail files, consider using additional Data Pump processes so fewer Replicat processes are reading
from the same files concurrently. For an example, refer to item 2d in the preceding section.
If there are no bottlenecks on the Replicat process (not constrained by CPU or trail file I/O), but lag is being reported
for the Replicat process, it is likely due to one of the integrated apply processes. Use SPADV (see previous
examples) to identify which process is bottlenecked and then use the following to guide you in resolving it:
Reduce the number of foreign key or primary key constraints to reduce the key dependency
computations.
Increase the source transaction sizes to reduce the overhead of transaction dependency tracking.
Create multiple integrated Replicat processes and manually partition groups of dependent objects
between them. This is covered earlier in the section titled Multiple Replicat Processes.
If constrained by CPU and if the SQL Statistics AWR report shows small numbers of rows per execution, enable
Replicat BATCHSQL or increase the size of BATCHTRANSOPS.
When BATCHSQL is enabled, the rows per execution increases and the elapsed time decreases, as shown in the
following report:
It is possible that the apply server processes are contending for database resources, much in the same way a user
process does. For example, for I/O, data block accesses, or index block updates. In such scenarios, SPADV or
AWR indicate this.
Note that the apply server processes are considered background processes and, therefore, are included in the
background wait events section of the AWR report.
The following AWR report shows that the SQL being applied by Oracle GoldenGate has the highest I/O wait times:
In such cases, evaluate database or object tuning techniques to improve performance. Refer to Oracle Database
Performance Tuning Guide at the following URL:
http://docs.oracle.com/database/121/TGDBA/E49058-04.pdf
f. If the target database AWR report shows single row operations executed by the Replicat process, consider using
BATCHSQL to take advantage of array processing in the database and reduce CPU usage.
The following is an example from an AWR report of non-integrated Replicat without BATCHSQL enabled, showing
single row operations:
In contrast, the following is an example using the BATCHSQL OPSPERBATCH parameter (number of operations the
Replicat process tries to batch together) set to the default value of 1200:
The rows per execution have increased to approximately 1000 and there is a 4.8 times reduction in elapsed time
and, consequently, the CPU consumed is also reduced (not shown in the previous example).
g. If using BATCHSQL and a Replicat process is not applying data fast enough, evaluate database or object tuning
techniques to improve performance. Refer to Oracle Database Performance Tuning Guide at the following URL:
http://docs.oracle.com/database/121/TGDBA/E49058-04.pdf
h. If database or object tuning does not help, configure additional Replicat processes and divide the work of the slow
performing Replicat process (method described earlier in this white paper) between multiple Replicat processes.
Workload Description
The Swingbench Order Entry workload is an Order Entry OLTP type benchmark, much like TPC-C. Swingbench
was modified to remove many of the queries and sleep time to create a more DML-intensive workload against the
database.
The workload applies DML against three tables: ORDERS, ORDER_ITEMS and INVENTORIES. The following figure
shows the parent-child relationships that exist between tables in the schema:
The workload was staged such that the Oracle GoldenGate processes were not started until the workload was
completed to determine how fast the data could be replicated.
Environment Configuration
The source and target hardware are Oracle Exadata Database Machine X2-2 quarter racks using three storage
cells.
The source and target database software are both release 12.1.0.2.
Both databases were configured with the following initialization parameters and values:
STREAMS_POOL_SIZE = 8G
DB_CACHE_SIZE = 8G
LOG_BUFFER = 128000000
SHARED_POOL_SIZE = 1536M
o MAX_SGA_SIZE = 2048
o 500MB trail files stored on DBFS configured according to instructions in the Oracle GoldenGate
on Exadata Database Machine Configuration white paper at the following URL:
http://www.oracle.com/technetwork/database/features/availability/maa-wp-gg-oracledbm-
128760.pdf
A single Data Pump using the PASSTHRU parameter to reduce CPU usage
Multiple Replicat processes configured and tuned using the details in the section titled Oracle GoldenGate
Performance.
Using a single integrated Extract process (configuration was discussed earlier in this white paper), the workload was
extracted from the redo logs and the trail files written in 13 minutes and 34 seconds. Reading the 106GB of redo
generated by the workload, this equates to a redo read rate of 134MB/second.
The Data Pump kept up with Extract and completed as soon as Extract had written the last entry in the source trail
file.
On the target database, a single Replicat process with BATCHSQL disabled was initially configured. The single
process took almost 8.5 hours to apply the workload. Using the performance tuning methodology previously
outlined, this time was reduced to approximately 24 minutes. The following table shows the effects of adding
additional Replicat processes with BATCHSQL enabled on the apply time:
* The Replicat apply rate is the rate at which the Replicat processes applied the workload-generated redo at the
source database. For example, if the source workload generated 106GB, and the Replicat process applied the
workload at the target database in approximately 24 minutes, the Replicat apply rate would be 78.1MB/second
(106GB every 24 minutes).
In order to distribute the apply work between the non-integrated Replicat processes, any foreign key
constraints must be disabled or dropped to allow the transactions to be distributed between the processes.
When the foreign key constraints are enabled in the Swingbench schema, the integrated Replicat performs
4.5 times faster than a single non-integrated Replicat (with BATCHSQL enabled).
Using an integrated Replicat process with BATCHSQL enabled, applying the workload is 4.8 times faster
than a single non-integrated Replicat. The single integrated Replicat is 12% faster than eight manually
configured non-integrated Replicat processes.
When using multiple non-integrated Replicat processes, performance improves by a factor of 3.4 times
when comparing a single Replicat process to eight Replicat processes.
Performance improves by a factor of 3.4 times when enabling BATCHSQL for a non-integrated Replicat
process.
These performance numbers are particular to the workload and the environment used for this testing. As with all
performance comparisons, your extract and apply rates may differ.
In order to optimize an Oracle GoldenGate environment, the following crucial pieces of data need to be gathered:
CPU data
I/O data
Oracle Streams Performance Advisor (SPADV) for integrated Extract and integrated Replicat
With all of this information gathered, the presented tuning methodology can be followed to identify and resolve the
current cause of lag or latency.
Performance tuning is an iterative process, such that when the cause of lag is resolved, the process begins again
with data gathering and analysis.
Using this approach, the previously described performance tuning exercise with a Swingbench OLTP workload
demonstrated how Oracle GoldenGate Extract to Replicat performance could be increased by a factor of 20 times.
Replicat apply rate of the source redo increased from 3.8MB/second to 78.1MB/second using an integrated Extract
and integrated Replicat configuration.
sleep 15
-- Now loop through showing results every 15 seconds, until CTRL-C is issued
d=0
while [ $d -lt 1 ];
do
date
begin
utl_spadv.show_stats(path_stat_table=>'STREAMS\$_PA_SHOW_PATH_STAT',
bgn_run_id=> -1,
end_run_id=> -1,
show_legend=> FALSE);
end;
/
!EOS
sleep 15
done
Using these statistics, you can divide the number of rows between the Replicat processes being configured. The
Perl code listed at the end of this Appendix takes an Extract or Replicat report file containing table statistics as an
argument. The maximum number of configurable Replicat processes is based on the largest row count for a single
table being the target number of rows to evenly allocate to each Replicat process.
The following Perl code does not consider further division of a large table between Replicat processes using the
FILTER parameter. To do this takes some manual intervention to understand the consequences of possible DDL
commands with foreign key and primary key relationships, as described earlier.
Step 1: Run the balance_replicats.pl script to determine the total row counts per table. For example:
% ./balance_replicats.pl ext_1a.rpt
Reading Extract report file: EXT_1A_HiDepSwing.rpt
**** ALL tables found in Extract report file (ordered by row count)***
SOESMALL.ORDER_ITEMS 45200510 37.3%
SOESMALL.INVENTORIES 39708064 32.7%
SOESMALL.ORDERS 32231079 26.6%
SOESMALL.LOGON 2055225 1.7%
SOESMALL.CUSTOMERS 2053397 1.7%
** Replicat Configuration **
Replicat# 1 - Tables: 1 Rows: 45200510
Step 3: Place the MAP statements provided into the Replicat parameter files to apply only the specified tables.
NOTE: Before dividing the tables between Replicat processes, you must consider any foreign key and primary key
relationships. If present, either keep the related tables in the same Replicat process or disable the constraints.
Using a Swingbench OLTP workload example, Replicat maximum latency decreased from 31 minutes to 3 seconds
using this approach.
balance_replicats.pl:
#!/usr/bin/perl
#
# balance_replicats.pl - Reads an Extract/Replicat report file or logdump
# outfile to try and evenly divide up the tables
# between multiple replicat processes
#
# The Extract or Replicat report file must contain table statistics, for example:
#
# From Table PSFT.PS_PAY_EARNINGS:
# # inserts: 2352256
# # updates: 4204032
# # deletes: 250240
# # discards: 0
#
# Alternatively, logdump can be used (see MOS note 1301300.1 for details) to show
# count of table data, and must include data:
#
# SOESMALL.INVENTORIES Partition 4
# Table data
my %table_data;
my %Replicat; # Hash table to store table and replicat number
# First need to determine what type of file being read, Report or Logdump
# For each table Extract/Replicat report file includes:
# From Table <owner>.<table_name>
# For logdump will include:
# Current LogTrail is
#
$rpt_string="From Table";
$logdmp_string="Current LogTrail is";
open(FH, $filename);
$table_count = 0;
if ($where != -1) {
$done = 1;
$tablename=$words[0];
$total = $bytes;
$table_count++;
$row_total = $row_total + $total;
}
}
}
}
print "\nNumber of tables read in file: $table_count\n";
close FILE;
} # End of readReportFile
$table_count = 0;
$where = index("$line", "** Run Time Statistics **"); #Find start of TOP
interval
$tablename=$words[2];
chop($tablename); # Remove the ":" from each tablename
$line = <FILE>;
@words = split (':',$line);
$upd = rtrim($words[1]);
$line = <FILE>;
@words = split (':',$line);
$del = rtrim($words[1]);
if (exists $table_data{$tablename}) {
print "** WARNING: Table $tablename already found in report file. This
should not happen.\n";
}
else {
$table_data{$tablename} = $total;
$table_count++;
$row_total = $row_total + $total;
}
}
################
# ** MAIN ** #
################
($filename) = @ARGV;
$max_total = 0;
$row_total = 0;
if ( $result == 1 ) {
# Read the Extract/Replicat report file:
readReportFile();
$logdump=0;
$which='Rows';
}
elsif ( $result == 2 ) {
readLogDump();
$logdump=1;
$which='Bytes';
}
else {
print "\n*** ERROR: Cannot determine if file is Report file or Logdump file -
check file correctness\n\n";
exit 1;
}
if ( $logdump ) {
print "Total Bytes: $row_total\n";
print "\n**** ALL tables found in Logdump file (ordered by bytes)***\n";
}
else {
print "Total Rows: $row_total\n";
print "\n**** ALL tables found in Extract report file (ordered by row
count)***\n";
}
if ( $max_replicats > 1 ) {
$done=0;
while ( $done != 1 ) {
print "\n Enter number of Replicat processes required (1 to $max_replicats): ";
$replicats = <STDIN>;
chomp ($replicats); # Remove carriage return
if ( $replicats > 0 && $replicats <= $max_replicats ) {
$done = 1;
}
}
}
else {
$replicats = $max_whole_replicats;
}
# Delete element from master hash of all tables to make sure does not get assigned
# again
delete($table_data{$table});
}
}
# Any tables left should be added to the replicat with the least number of rows!
my $entry = $Replicat{$minrep};
$entry->{num_rows} = $entry->{num_rows}+$total;
push(@{$entry->{$tables}}, $table);
}
print "\n";
}
exit;
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license
licens and
aree trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are
trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. 1114