Offloading Reports to an Active Data Guard Standby in Another Cloud
A physical standby usually sits mounted, applying redo and doing nothing else until the day of a disaster. If the reporting and analytics tools run in a different cloud from production, that idle standby can be the most useful database you have: a current copy of production, close to the reporting tools, which can take the heavy queries off the primary.
Active Data Guard makes that possible. The standby opens read-only while redo apply continues, so queries see data that is only seconds behind the primary. This post opens the standby in Azure for reporting, routes the reporting tools to it with a role-based service, controls how stale the data may be, allows the occasional write, and shows what to monitor.
The Use Case
The primary runs on OCI and serves the order-entry application. The business intelligence tools run in Azure and hit the primary with long reporting queries every morning, competing with order entry. The physical standby already runs in Azure for disaster recovery. The goal is to move all reporting to the standby, with data no more than a minute old, without changing the reports.
Environment used in this runbook
Primary: SALES_OCI, Oracle Database 19c (19.24) on an OCI VM, container database with PDB SALESPDB
Standby: SALES_AZURE, physical standby on an Azure VM, managed by the Data Guard broker, Grid Infrastructure for services
Reporting: BI tools on Azure VMs, connecting through Oracle Net
Licence: opening a physical standby read-only while redo apply runs is the Active Data Guard option, an extra-cost licence for Enterprise Edition on both databases
What Active Data Guard Adds
Real-time query. The standby is open READ ONLY WITH APPLY: queries run while redo is applied, and see a consistent, current view of the data.
Role-based services. A service can be defined to start only when the database is a physical standby, so reporting tools follow the standby role automatically, including after a switchover.
Lag control. A session can say how stale is acceptable, and get an error instead of silently old data.
DML redirection. Since 19c, the occasional INSERT or UPDATE issued on the standby can be sent transparently to the primary, which helps tools that write a small log table.
Step 1: Check the Standby's Current State
Before opening anything, confirm the configuration is healthy and see how the standby runs today.
SQL |
-- On the standby SALES_AZURE SELECT db_unique_name, database_role, open_mode FROM v$database;
COLUMN name FORMAT A14 COLUMN value FORMAT A14
SELECT name, value FROM v$dataguard_stats WHERE name IN ('transport lag', 'apply lag'); |
Expected output |
DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE
---------------- ---------------- --------------------
SALES_AZURE PHYSICAL STANDBY MOUNTED
NAME VALUE
-------------- --------------
transport lag +00 00:00:00
apply lag +00 00:00:01What to expect: A mounted physical standby with no meaningful lag. A standby that already lags behind will lag further once it also runs reports, so fix any existing lag first (see the Data Guard lag diagnosis post on this blog).
Step 2: Open the Standby Read-Only with Apply
Stop redo apply through the broker, open the database read-only, open the PDB, and restart apply. The broker records the new state, so the standby comes back the same way after a restart.
Shell |
dgmgrl / "edit database 'SALES_AZURE' set state='APPLY-OFF'"
sqlplus -s / as sysdba <<'EOF' ALTER DATABASE OPEN READ ONLY; ALTER PLUGGABLE DATABASE salespdb OPEN READ ONLY; EOF
dgmgrl / "edit database 'SALES_AZURE' set state='APPLY-ON'" |
Expected output |
Succeeded.
Database altered.
Pluggable database altered.
Succeeded.What this does: The standby is now open for queries and applying redo at the same time. On a standby managed by Grid Infrastructure, also set the start option so it opens read-only after a restart: srvctl modify database -db SALES_AZURE -startoption "READ ONLY".
Step 3: Confirm Real-Time Query Is Active
Check the open mode and confirm that apply is running in real time, applying from the standby redo logs rather than waiting for archived logs.
SQL |
SELECT open_mode FROM v$database;
COLUMN name FORMAT A8 COLUMN role FORMAT A22 COLUMN action FORMAT A13
SELECT name, role, action FROM v$dataguard_process WHERE name IN ('MRP0', 'PR00'); |
Expected output |
OPEN_MODE
--------------------
READ ONLY WITH APPLY
NAME ROLE ACTION
-------- ---------------------- -------------
MRP0 managed recovery IDLE
PR00 recovery logmerger APPLYING_LOGWhat to expect: READ ONLY WITH APPLY, and the recovery processes applying redo. This open mode is what requires the Active Data Guard licence; a plain READ ONLY without apply does not, but then the data stops moving while the database is open.
Step 4: Create a Reporting Service That Runs Only on the Standby
The reporting tools must connect to whichever database is the standby, never to the primary. A role-based service does exactly that. Create it on both databases with the same name, so it follows the standby role after a switchover.
Shell |
# On the standby host srvctl add service -db SALES_AZURE -pdb SALESPDB \ -service sales_reports.example.internal -role PHYSICAL_STANDBY -policy AUTOMATIC srvctl start service -db SALES_AZURE -service sales_reports.example.internal
# On the primary host: same service, so it starts there only if that database becomes the standby srvctl add service -db SALES_OCI -pdb SALESPDB \ -service sales_reports.example.internal -role PHYSICAL_STANDBY -policy AUTOMATIC
srvctl status service -db SALES_AZURE -service sales_reports.example.internal |
Expected output |
Service sales_reports.example.internal is running on instance(s) SALES1What this does: The service runs on SALES_AZURE because it is the physical standby, and stays down on SALES_OCI while that database is primary. After a switchover, Clusterware stops it on the new primary and starts it on the new standby. Point the BI tools' connect string at sales_reports.example.internal, with both databases' listener addresses in the address list.
Step 5: Move a Report and Compare
Run a typical report through the new service and compare its elapsed time and its effect on the primary. On the standby, the report reads data that is current to within seconds.
SQL |
-- Connected through sales_reports.example.internal SET TIMING ON
SELECT region, TRUNC(order_date, 'MM') AS month, SUM(amount) AS revenue FROM sales.orders WHERE order_date >= DATE '2026-01-01' GROUP BY region, TRUNC(order_date, 'MM') ORDER BY region, month FETCH FIRST 3 ROWS ONLY; |
Expected output |
REGION MONTH REVENUE
---------- --------- ----------
CENTRAL 01-JAN-26 18442106
CENTRAL 01-FEB-26 17951320
CENTRAL 01-MAR-26 19310882
Elapsed: 00:00:41.27What to expect: The report returns the same results it gives on the primary and takes a comparable time, now without touching the primary's CPU or I/O. Measure the primary's load before and after the move: the morning peak should drop by roughly the load the reports used to add.
Step 6: Set a Maximum Acceptable Lag
Some reports must not run on stale data. STANDBY_MAX_DATA_DELAY sets, per session, how many seconds behind the primary the standby may be. If the apply lag is larger, queries fail with ORA-03172 instead of returning old results.
SQL |
-- In the report session (or in a logon trigger for the reporting user) ALTER SESSION SET standby_max_data_delay = 60;
SELECT COUNT(*) AS orders_today FROM sales.orders WHERE order_date >= TRUNC(SYSDATE); |
Expected output |
Session altered.
ORDERS_TODAY
------------
18446What to expect: The query runs normally while the lag is under 60 seconds. If apply falls further behind, the same query returns ORA-03172: STANDBY_MAX_DATA_DELAY of 60 seconds exceeded, which is a clear signal to the reporting tool instead of quietly wrong numbers. A value of 0 means the standby must be fully in sync with the primary, which in practice needs synchronous transport.
Step 7: Allow the Occasional Write with DML Redirection
Many BI tools write a little: a log row, a bookmark, a refresh timestamp. On a read-only standby those statements fail. In 19c, DML redirection sends them to the primary over a database link that Oracle manages internally, and the change then arrives back on the standby through redo.
SQL |
-- On the primary, so the setting is the same after a switchover ALTER SYSTEM SET adg_redirect_dml = TRUE SCOPE = BOTH;
-- On the standby, connected through the reporting service as the BI user INSERT INTO bi_admin.report_runs (report_name, run_time) VALUES ('MONTHLY_REVENUE', SYSTIMESTAMP); COMMIT;
SELECT COUNT(*) AS runs_today FROM bi_admin.report_runs WHERE run_time >= TRUNC(SYSDATE); |
Expected output |
System altered.
1 row created.
Commit complete.
RUNS_TODAY
----------
12What this does: The INSERT executed on the standby is redirected to the primary and committed there; the COMMIT on the standby waits until the change has been applied back, so the session sees its own write. Each redirected statement costs a round trip between the clouds, so this is for occasional writes, not for loading data. Set the parameter on both databases, or only for specific sessions with ALTER SESSION ENABLE ADG_REDIRECT_DML.
Tip: Global temporary tables also work on an Active Data Guard standby, because temporary undo is used there automatically. Reports that stage intermediate results in a global temporary table usually run unchanged.
Step 8: Watch Apply While Reports Run
Heavy reports and redo apply share the standby's CPU and I/O. Check during the reporting peak that apply keeps up, and see which queries are running.
SQL |
SELECT name, value FROM v$dataguard_stats WHERE name IN ('transport lag', 'apply lag');
COLUMN service_name FORMAT A30
SELECT service_name, COUNT(*) AS active_sessions FROM v$session WHERE status = 'ACTIVE' AND type = 'USER' GROUP BY service_name; |
Expected output |
NAME VALUE
-------------- --------------
transport lag +00 00:00:00
apply lag +00 00:00:03
SERVICE_NAME ACTIVE_SESSIONS
------------------------------ ---------------
sales_reports.example.internal 14What to expect: Apply lag of a few seconds with 14 active report sessions: the standby keeps up. If the lag climbs during the peak, either limit the reporting sessions with Resource Manager on the standby, or give the standby VM more CPU or faster storage. Remember the standby's first job is still disaster recovery.
Step 9: Check What a Switchover Does
Before you rely on this setup, rehearse a switchover in a maintenance window and confirm that the reporting service moves to the new standby on its own.
Shell |
dgmgrl sys@SALES_OCI "switchover to 'SALES_AZURE'"
srvctl status service -db SALES_OCI -service sales_reports.example.internal |
Expected output |
Performing switchover NOW, please wait...
Operation requires a connection to database "SALES_AZURE"
Connecting ...
Connected to "SALES_AZURE"
Connected as SYSDBA.
New primary database "SALES_AZURE" is opening...
Operation requires start up of instance "SALES1" on database "SALES_OCI"
Starting instance "SALES1"...
Connected to an idle instance.
ORACLE instance started.
Connected to "SALES_OCI"
Database mounted.
Database opened.
Connected to "SALES_OCI"
Switchover succeeded, new primary is "SALES_AZURE"
Service sales_reports.example.internal is running on instance(s) SALES1What to expect: The switchover succeeds, SALES_OCI comes back as the standby and opens read-only (with the start option set as in Step 2), and the reporting service now runs on SALES_OCI. The BI tools reconnect through the same service name. Switch back afterwards, and check the reporting service returns to SALES_AZURE.
Summary
Active Data Guard turns a disaster recovery standby into a reporting database in another cloud, close to the tools that use it. Check the configuration, open the standby read-only and restart apply, and confirm READ ONLY WITH APPLY. Create a role-based reporting service on both databases so reports always land on the standby, set STANDBY_MAX_DATA_DELAY where stale data is not acceptable, and enable DML redirection for the few writes the tools make. Watch the apply lag during the reporting peak, rehearse a switchover, and keep in mind that the Active Data Guard option must be licensed on both databases.
Comments