PostgreSQL 20 is getting a new system function `pg_stat_get_backend_lock()` that provides per-backend lock statistics. This allows DBAs to query lock wait counts, wait times, and fastpath exceeded counts for individual backends by PID, complementing the existing `pg_stat_lock` view which only shows aggregate data. The feature is useful when joined with `pg_stat_activity` to diagnose lock contention in live production systems. The post demonstrates the feature with a practical example showing two backends blocked by an access exclusive lock.
2.1K Impressions