Once you have found out that a query is blocked, you need to know who or what is blocking them.
Knowing who is blocking a query
Getting ready
If you are logged in as a superuser you will have full access to monitoring information.
How to do it...
- You can write the following query:
SELECT datname
, usename
, wait_event_type
, wait_event
, pg_blocking_pids(pid) AS blocked_by
, query
FROM pg_stat_activity
WHERE wait_event_type IS NOT NULL
AND wait_event_type NOT IN ('Activity', 'Client');
- You will get an output like the following:
-[ RECORD 1 ]---+-------...