Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with blocked as (
- select pid,
- usename,
- client_addr,
- application_name,
- pg_blocking_pids(pid) as blocked_by,
- query as blocked_query
- from pg_stat_activity
- where cardinality(pg_blocking_pids(pid)) > 0
- ), cteBlockingHierarchy as (
- SELECT
- all_query.pid,
- all_query.usename,
- all_query.client_addr,
- all_query.application_name,
- pg_blocking_pids(all_query.pid) as blocked_by,
- all_query.query as blocked_query
- from pg_stat_activity all_query
- RIGHT JOIN blocked
- on all_query.pid = any(blocked.blocked_by)
- union
- SELECT * from blocked
- )
- SELECT * from cteBlockingHierarchy;
- -- SELECT pg_terminate_backend(20190);
- -- select pg_cancel_backend(220464);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement