DEV Community

dimas
dimas

Posted on

How to detect query which holds the lock in Postgres?

How to detect query which holds the lock in Postgres?

select pid, 
       usename, 
       pg_blocking_pids(pid) as blocked_by, 
       query as blocked_query
from pg_stat_activity
where cardinality(pg_blocking_pids(pid)) > 0;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)