SQL Queries - Common SQL Queries - How to check the postgres sessions that are blocking another session

Purpose of Query

The purpose of this query is to find the postgres sessions that are blocking another postgres session. 

Applicable CAST Version
Release
Yes/No
8.3.x(tick)
Applicable RDBMS
RDBMS
Yes/No
Oracle Server(question)
Microsoft SQL Server(question)
CSS4(tick)
CSS3(tick)
CSS2(tick)
Query for CSS
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;
Query result example
 
Query result interpretation
 The query will determine if there are any other postgres sessions blocking the current postgres session.
Notes/comments

  

Related Pages