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_startThis 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