Skip to main content

Lock Contention Analysis

The Lock Contention Analysis section provides a detailed view of lock waits and blocking activity during the report period. It helps identify which queries were blocked, which queries caused the most blocking, and which database objects experienced the most contention.

AWR Lock Analysis


Summary Cards

Four summary cards give an immediate overview of lock activity:

CardDescription
Total Locks WaitedTotal number of lock wait events observed during the period
Total Wait TimeCumulative lock wait time — also expressed as a percentage of DB Time
Avg Wait TimeAverage wait time per lock wait event
DeadlocksTotal number of deadlocks detected — card turns orange if > 0

AWR Lock Summary Cards


Lock Contention Timeline

A timeline chart shows lock contention activity over the report period, allowing you to identify when contention peaks occurred.

AWR Lock Contention Timeline


Tab 1 — Top Waiting Queries

Queries that experienced the most lock wait time — sessions that were blocked by other sessions holding locks.

ColumnDescription
RankPosition by total wait time
SQL TextNormalized query text (truncated) with User, Database and Application context
Wait TimeTotal lock wait time in seconds
% TotalShare of total lock wait time
Sessions AffectedNumber of distinct sessions that executed this query and waited
Wait CountNumber of wait samples observed
Avg WaitAverage wait time per occurrence
DetailsOpens the Waiting Query Details dialog

AWR Top Waiting Queries

Waiting Query Details Dialog

Click the eye icon to open a detail panel for a waiting query:

  • SQL Statement — full query text with copy button
  • Metrics — Total Wait Time, Sessions Affected, Wait Count, Avg Wait Time
  • Execution Context — User, Database, Application name
  • Query Hash — normalized query identifier with copy button
  • Recommendations — contextual recommendations based on wait severity

Tab 2 — Top Blocking Queries

Queries that blocked other sessions the most — sessions holding locks that prevented others from progressing.

ColumnDescription
RankPosition by total blocking time
SQL TextNormalized query text with execution context
Blocking TimeTotal time this query blocked other sessions
% TotalShare of total blocking time
Blocked SessionsNumber of distinct sessions blocked by this query
OccurrencesNumber of distinct blocking events
Avg DurationAverage duration per blocking occurrence
DetailsOpens the Blocking Query Details dialog

AWR Top Blocking Queries

Blocking Query Details Dialog

  • SQL Statement — full query text with copy button
  • Metrics — Total Blocking Time, Blocked Sessions, Blocking Occurrences, Avg Duration, Max Duration
  • Execution Context — User, Database, Application name
  • Query Hash — with copy button
  • Recommendations — contextual recommendations based on blocking severity

Tab 3 — Wait Events by Type

Lock wait events grouped by lock type and lock mode.

ColumnDescription
RankPosition by total wait time
Lock TypeType of lock (relation, transactionid, tuple, LWLock, etc.)
Lock ModeLock mode requested
Total Wait TimeCumulative wait time for this lock type
% TotalShare of total lock wait time
Wait CountNumber of wait events of this type
Avg WaitAverage wait time per event
Max WaitLongest observed wait for this lock type
Affected ObjectsNumber of distinct objects involved

AWR Lock Wait Event By Type


Tab 4 — Contention by Object

Tables and indexes ranked by total lock contention time.

ColumnDescription
RankPosition by contention time
TypeObject type (TABLE, INDEX, etc.)
ObjectObject OID and name
Contention TimeTotal contention time on this object
% TotalShare of total contention time
OccurrencesNumber of contention events on this object
Avg DurationAverage contention duration per event
Lock TypesLock types observed on this object (badges)
Affected SessionsNumber of distinct sessions affected

AWR Contention By Object


Tab 5 — Deadlock History

Chronological list of deadlock events detected during the report period.

ColumnDescription
RankChronological position
Occurrence TimeTimestamp of the deadlock event
DatabaseDatabase where the deadlock occurred
Deadlock CountNumber of deadlocks at this timestamp
SnapshotSnapshot ID during which the deadlock was recorded
info

Deadlock details (involved queries and victim sessions) are available in the PostgreSQL server logs. Cross-reference the deadlock timestamp with your log files for full investigation.

AWR Deadlock History


Interpretation Guide

High Lock Wait as % of DB Time

Lock contention is a significant contributor to database slowness. Review the Top Blocking Queries tab to identify the root cause and shorten transaction durations.

High Avg Wait Time

Sessions are waiting a long time for each lock acquisition. Investigate long-running transactions that hold locks for extended periods.

Frequent transactionid Waits

Sessions are waiting for other transactions to commit or rollback. Ensure transactions are as short as possible and that application error handling includes proper rollback.

Frequent relation or tuple Waits

Row or table level contention. Review lock modes used by concurrent queries — consider SELECT FOR UPDATE SKIP LOCKED for queue-like patterns.

Any Deadlocks > 0

Investigate deadlock patterns in PostgreSQL logs. Ensure consistent lock acquisition order across the application.


Next Steps