denrepo

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

b-pg-idletx.sql
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.

Open in denrepo

More PostgreSQL scripts: Sessions