pg_stat_lock — PostgreSQL statistics view

The PostgreSQL pg_stat_lock statistics view: full column reference (names, types, descriptions), catalog relationships and version support.

Summary

The pg_stat_lock view will contain one row for each lock type, showing cluster-wide locks statistics.

(Description quoted from the official PostgreSQL documentation.)

Columns

The pg_stat_lock statistics view exposes the following columns (names, types and descriptions are taken verbatim from the PostgreSQL documentation):

  • locktype text
    Type of the lockable object. See pg_locks for details.
  • waits bigint
    Number of times a lock of this type had to wait because of a conflicting lock. Only incremented when the lock was successfully acquired after waiting longer than deadlock_timeout.
  • wait_time bigint
    Total time spent waiting for locks of this type, in milliseconds. Only incremented when the lock was successfully acquired after waiting longer than deadlock_timeout.
  • fastpath_exceeded bigint
    Number of times a lock of this type could not be acquired via fast path because the fast path slot limit was exceeded. Increasing max_locks_per_transaction can reduce this number.
  • stats_reset timestamp with time zone
    Time at which these statistics were last reset.

Version applicability

Present in PostgreSQL 19 (verified against each release’s documentation). This object was introduced in PostgreSQL 19.

Related & references

Reference: PostgreSQL documentation — pg_stat_lock.