Skip to content

PopSQL: limited support.

Migrate now →

Transactions open for more than 5 minutes

Sessions holding a transaction open, including idle-in-transaction ones, which block vacuum and hold locks while doing nothing.

PostgreSQL · SQL
SELECT pid,
       usename AS user_name,
       application_name,
       client_addr,
       state,
       EXTRACT(EPOCH FROM (now() - xact_start))::int AS open_seconds,
       LEFT(query, 200) AS query
FROM pg_stat_activity
WHERE xact_start IS NOT NULL
  AND now() - xact_start > interval '5 minutes'
  AND pid <> pg_backend_pid()
ORDER BY xact_start

This query is part of the "PostgreSQL health" pack: connect the database in DataRunner and install the whole pack — queries, dashboard and checks — at once.

  • Check that ships with it: No transaction open for more than 5 minutes