May 2018
Intermediate to advanced
576 pages
30h 25m
English
SELECT datname, usename, wait_event_type, wait_event, pg_blocking_pids(pid) AS blocked_by, queryFROM pg_stat_activityWHERE wait_event_type IS NOT NULLAND wait_event_type NOT IN ('Activity', 'Client');
-[ RECORD 1 ]---+-----------------datname | postgresusename | gianniwait_event_type | Lockwait_event | relationblocked_by | {18142}query | select * from t;
This is in fact the query described in the previous recipe, with the addition of the column called blocked_by. Recall that the PID is the unique identifier assigned by the operating system to each session; for more details, see Chapter 4, Server Control. Here the PID is used by the pg_blocking_pids(pid) ...