Long-running transactions#
What it does
Shows transactions running longer than a specified duration.
Use when
- Database-backed requests are slow or timing out.
- Vacuum cannot remove old row versions.
Inspect
- Transactions with unusually old xact_start values.
- Sessions that are idle in transaction or may be retaining locks.
Result
Current state at execution time.
Columns#
| Column | Meaning |
|---|---|
datname |
Database to which the session is connected. |
duration |
Time elapsed since the transaction began. |
pid |
PostgreSQL backend process ID. |
query |
Most recently observed statement in the session. |
state |
Current backend state. |
usename |
Connected PostgreSQL role. |
xact_start |
Time at which the current transaction began. |
Parameters#
| Option | Type | Default | Description |
|---|---|---|---|
--limit |
integer, minimum 1, accepts NULL | 20 |
Maximum number of rows to show. Use NULL for no limit. |
--minimum-duration |
duration | 5m |
Minimum transaction duration. |
Privileges#
Without membership of pg_monitor, other sessions' query text and statistics may be hidden, and pgcue warns that results may be incomplete.
Compatibility#
- PostgreSQL 14+