Read PG stat lock
read_pg_stat_lockMonitor lock contention in PostgreSQL by reading per-lock-type acquire, wait, and wait-time counters from pg_stat_lock. Works on PG 19+; returns empty list on older versions.
Instructions
Return every row from PG 19's pg_stat_lock view (per-lock-type acquire / wait / wait-time counters since the most recent pg_stat_reset). Empty list on PG < 19 or when the view isn't present. Returns a list of objects with lock_type (relation / page / tuple / xid / virtualxid / advisory / ...), acquires, waits, and wait_time_us.
Example: read_pg_stat_lock()
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |