Skip to content

Logical Standby SCN Analysis (what_scn.sql)

This script analyzes logical standby database SCN (System Change Number) progression by:

  • Showing all logical standby processes and their current SCN positions
  • Identifying apply processes with minimum SCN values
  • Highlighting processes with specific error status codes (16123, 16124)
  • Displaying overall logical standby progress information
set lines 140 numw 16
vol status format a40 trunc
select logstdby_id,pid,type,status,high_scn from v$logstdby where type != 'APPLIER'
union all
select logstdby_id,pid,type,status,high_scn from v$logstdby l where type = 'APPLIER' and high_scn =
( select min(high_scn) from v$logstdby l1 where l.type = l1.type )
union all
select logstdby_id,pid,type,status,high_scn from v$logstdby l where type = 'APPLIER' and high_scn =
( select min(high_scn) from v$logstdby l1 where l.type = l1.type and l1.status_code in ( 16123 ) )
union all
select logstdby_id,pid,type,status,high_scn from v$logstdby l where type = 'APPLIER' and high_scn =
( select min(high_scn) from v$logstdby l1 where l.type = l1.type and l1.status_code in ( 16124 ) )
order by 4 desc
/
set lines 80
select * from v$logstdby_progress;
SQL> @what_scn.sql

This script must be run on a logical standby database.

  • SELECT on V$LOGSTDBY
  • SELECT on V$LOGSTDBY_PROGRESS
LOGSTDBY_ID PID TYPE STATUS HIGH_SCN
----------- ---------- -------------------------------- -------------------------------- ---------------
1 1234 READER READING LOG 12345678901234
1 2345 PREPARER APPLYING 12345678901234
1 3456 BUILDER APPLYING 12345678901234
1 4567 APPLIER APPLYING 12345678901230
1 5678 APPLIER APPLYING 12345678901230
LOGSTDBY_ID TYPE STATUS APPLIED_TIME NEWEST_TIME APPLIED_SCN NEWEST_SCN READ_scn applied_lwm_scn spill_scn
----------- -------- -------------------------------- ------------------------------ ------------------------------ -------------- -------------- ----------- ----------- ----------
1 LOGICAL APPLYING 15-JAN-24 14:30:45 15-JAN-24 14:35:22 123456789 123456790 123456790 123456789 0
  • LOGSTDBY_ID: Logical standby identifier
  • PID: Process ID of the logical standby process
  • TYPE: Process type (READER, PREPARER, BUILDER, APPLIER)
  • STATUS: Current status of the process
  • HIGH_SCN: Highest SCN processed by this process
  • APPLIED_TIME: Timestamp of last applied transaction
  • NEWEST_TIME: Timestamp of newest available transaction
  • APPLIED_SCN: Last SCN applied to the standby
  • NEWEST_SCN: Newest SCN available from primary
  • READ_SCN: SCN being read by log reader
  • APPLIED_LWM_SCN: Low watermark SCN for applied transactions
  • Reads redo logs from primary database
  • Should show “READING LOG” status
  • HIGH_SCN shows latest SCN read
  • Prepares LogMiner dictionary
  • Status should be “APPLYING” when healthy
  • Processes dependency information
  • Builds logical change records (LCRs)
  • Status should be “APPLYING” during normal operation
  • Handles complex object transformations
  • Applies transactions to standby database
  • Multiple applier processes can exist
  • Minimum SCN among appliers shows apply bottleneck
  1. Lag Analysis

    • Compare APPLIED_SCN vs NEWEST_SCN
    • Identify lagging applier processes
    • Monitor SCN progression rates
  2. Performance Troubleshooting

    • Find bottleneck processes
    • Check for process errors
    • Validate parallel apply efficiency
  3. Health Monitoring

    • Verify all processes are running
    • Check for status anomalies
    • Monitor SCN advancement
  • 16123: Specific logical standby error condition
  • 16124: Another logical standby error condition
  • Check Oracle documentation for specific error details
  • APPLYING: Normal operation
  • READING LOG: Log reader active
  • WAITING FOR LOG: Waiting for new redo
  • ERROR: Process encountered error
  1. Slow Reader: Check network/storage performance
  2. Slow Preparer: Review dictionary build time
  3. Slow Builder: Check for complex transformations
  4. Slow Applier: Consider adding parallel apply
  1. Stopped Processes: Check alert logs for errors
  2. Error Status: Review DBA_LOGSTDBY_EVENTS
  3. Uneven SCNs: May indicate process coordination issues
-- Increase parallel apply processes
ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE PARALLEL 4;
-- Check apply parameters
SELECT name, value
FROM v$parameter
WHERE name LIKE '%logstdby%';