Thursday, 25 January 2018

Find out blocked queries in PostgreSQL version 9.6 onwards

Below is the query that can be used to find out blocked queries in PostgreSQL version 9.6 onwards -

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;

No comments:

Post a Comment