PostgreSQLSessions
Long-running and idle-in-transaction sessions
Transactions open longer than five minutes. Idle-in-transaction sessions hold locks and stop vacuum from cleaning up.
Not yet verified. How scripts are tested
1SELECT pid, usename, datname, state,2 now() - xact_start AS xact_age,3 left(query, 150) AS last_query4FROM pg_stat_activity5WHERE xact_start IS NOT NULL6 AND now() - xact_start > interval '5 minutes'7ORDER BY xact_start;Paste it into your query tool.
More PostgreSQL scripts: Sessions
- Active queriesEvery non-idle backend with what it's waiting on and how long it's been running.
- Cancel a query or terminate a sessionTry cancel first: it stops the current statement and leaves the connection open. Terminate ends the backend and rolls back its transaction.