Database Monitoring   «Prev  Next»
Lesson 16Detecting redo log buffer contention
ObjectiveDetect and resolve contention for the redo log buffer.

Detecting redo log Buffer Contention

Detecting and resolving contention for the "redo log buffer" in Oracle 11g involves monitoring system performance, identifying symptoms of contention, analyzing relevant statistics, and applying specific tuning measures. Here’s an overview of the process:
  1. Detect Contention Symptoms
    • High Wait Times: One of the common symptoms of redo log buffer contention is high wait times on the event log buffer space.
    • Slow DML Operations: If insert, update, or delete operations are slower than expected, redo log buffer contention could be a contributing factor.
    • Poor System Performance: Overall degradation in performance, especially during high transactional workloads.
  2. Monitor and Identify Contentions
    • Use Oracle Dynamic Performance Views to monitor performance metrics related to the redo log buffer:
      • V$SYSTEM_EVENT: Check for the log buffer space wait event and analyze its wait times and counts.
      • V$SESSION_EVENT: View wait events at the session level for insights into individual session behavior.
      • V$SYSSTAT: Look for statistics such as redo entries, redo size, and redo buffer allocation retries.
    • Important Metrics:
      • redo buffer allocation retries: This statistic indicates the number of times a user process had to wait for space in the redo log buffer. If this value is continuously increasing, it signals redo log buffer contention.
      • Check the average wait time for the log buffer space wait event. High values suggest contention.
  3. Analyze the Root Cause
    • Insufficient Redo Log Buffer Size: The most common cause of contention is that the redo log buffer is too small to handle the volume of redo data generated.
    • Frequent Redo Log Switches: Frequent switches may indicate an issue with the redo log files themselves, contributing to contention.
    • High DML Volume: If the application generates a high volume of DML operations, the redo log buffer may be insufficient for peak loads.
  4. Resolve Contention Issues
    • Increase the Size of the Redo Log Buffer:
      • You can increase the redo log buffer size by adjusting the LOG_BUFFER initialization parameter. For most systems, a larger buffer size may reduce contention.
      • Guideline: The redo log buffer size is generally set between 1 MB to 5 MB for OLTP systems. For heavy workloads, consider sizing it appropriately based on performance testing.
    • Optimize Redo Generation:
      • Minimize the generation of unnecessary redo by using techniques such as:
        • Using NOLOGGING operations where feasible for bulk data loads.
        • Batching DML operations to reduce the overall redo generation.
    • Tune Log Writer (LGWR) Performance:
      • Ensure that the LGWR process can efficiently write redo entries from the buffer to the redo log files.
      • Place redo log files on fast storage devices to minimize write latency.
      • Check the I/O performance of the disks storing redo log files.
    • Review and Increase Redo Log File Sizes: Large redo log files reduce the frequency of log switches, which can help if contention is caused by frequent log switches.
    • Consider Workload Distribution: Spread out heavy DML operations if possible, to balance redo generation throughout the workload period.
  5. Monitor After Changes
    • After making adjustments, continue monitoring the system using V$SYSTEM_EVENT, V$SESSION_EVENT, and V$SYSSTAT to ensure that contention issues have been resolved and that the changes have a positive impact on performance.

redo log buffer

The redo log buffer is an area in memory where processes place redo log entries that need to be written to disk. If the buffer is too small and you have a lot of update activity, processes may have to wait in line to place data into the buffer. That's called redo log buffer contention. If it happens too often, it can affect performance. You can check for redo log buffer contention by monitoring a statistic named redo buffer allocation retries. The value for that statistic is incremented each time a process is forced to wait. You can check the value by querying a data dictionary view known as V$SYSTAT. Use a query like the one shown in this example:
SQL> SELECT name, value

  2  FROM v$sysstat

  3  WHERE name = 'redo buffer allocation retries';

NAME                                    VALUE

----------------------------------- ---------

redo buffer allocation retries          43982

Purpose of the v$sysstat Statistic in Oracle

The `V$SYSSTAT` view in Oracle provides cumulative system statistics that give insights into the overall performance and activity of the database. Each row in this view represents a specific statistic, which helps database administrators (DBAs) monitor and diagnose performance issues or resource usage.
Purpose of `V$SYSSTAT`
  1. Track System Activity: V$SYSSTAT tracks various types of system activity, such as the number of user commits, parse counts, physical reads, logical reads, and much more.
  2. Performance Analysis: The statistics help in identifying performance bottlenecks and understanding how efficiently the database is running.
  3. Resource Usage Monitoring: It provides details on how resources like CPU, memory, and I/O are being utilized, which aids in resource optimization.
  4. Troubleshooting and Tuning: By analyzing statistics, DBAs can pinpoint issues such as high redo generation, frequent buffer cache misses, or excessive parse operations and take corrective measures.
  5. Understanding Workloads: Helps in understanding the workload patterns on the database and how different components (like sessions, queries, or transactions) are affecting performance.

Examples of Important Statistics in `V$SYSSTAT`
  • redo entries: Number of redo entries generated. Useful to monitor the volume of redo data.
  • redo buffer allocation retries: Indicates how often user processes had to wait for space in the redo log buffer. A high value may suggest contention.
  • user commits: Number of user commit operations performed.
  • user rollbacks: Number of user rollback operations.
  • physical reads: Number of data blocks read from disk, used to analyze I/O performance.
  • session logical reads: Number of logical reads, which helps measure buffer cache efficiency.
  • parse count (hard): Number of hard parses, indicating how often SQL statements have to be fully parsed, which can be a performance concern.

How to Use `V$SYSSTAT` for Monitoring
  • Query the View: You can query V$SYSSTAT to get statistics for specific areas of interest:
    SELECT name, value FROM V$SYSSTAT WHERE name = 'redo entries';
        
  • Baseline Comparisons: Take snapshots of key statistics at regular intervals to compare performance over time.
  • Identify Trends: Use the statistics to observe trends, like increasing redo generation or frequent log switches, and analyze their impact on database performance.

Practical Use Cases
  • Redo Log Buffer Analysis: To analyze redo log buffer activity, look at statistics such as redo buffer allocation retries and redo entries.
  • SQL Execution Efficiency: Use statistics related to parsing, like parse count (total) and parse count (hard), to optimize SQL execution.
  • Memory Utilization: Check statistics like db block gets and consistent gets to understand the effectiveness of the buffer cache.
`V$SYSSTAT` is a powerful tool for gaining a comprehensive view of database performance and is often used in performance tuning and diagnostic efforts.
Ideally, this statistic should be as close to zero as possible. If you see it growing consistently over time, then you may be experiencing redo log buffer contention. To reduce the contention, increase the size of the redo log buffer. That's done by increasing the value of the log_buffer initialization parameter. Remember to stop and restart the database so that the parameter change will take effect. The next lesson is the module wrap-up. You will get a brief review of the topics we have covered in this module. Also, you can take a quiz that will help you verify what you have learned and discover topics that you might want to review in a more detailed manner.

SEMrush Software