Skip to content

Instantly share code, notes, and snippets.

@mjallday
Created September 4, 2012 17:37
Show Gist options
  • Save mjallday/3623938 to your computer and use it in GitHub Desktop.
Save mjallday/3623938 to your computer and use it in GitHub Desktop.
Slow transactions Postgres
select c.relname,
l.mode,
l.granted as "g",
a.current_query,
cast(a.query_start as time),
age(now(), a.query_start) as "age",
a.procpid,
a.client_addr
from pg_stat_activity a
inner join pg_locks l on a.procpid = l.pid
left outer join pg_class c on l.relation = c.oid
where age(now(), a.query_start) > interval '1 minutes'
order by a.query_start, l.pid;
select c.relname,
l.mode,
l.granted as "g",
a.current_query,
cast(a.query_start as time),
age(now(), a.query_start) as "age",
a.procpid,
a.client_addr
from pg_stat_activity a
inner join pg_locks l on a.procpid = l.pid
left outer join pg_class c on l.relation = c.oid
where a.query_start < NOW() - interval '1 minutes'
order by a.query_start, l.pid;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment