Skip to Content
PostgreSQL 10 Administration Cookbook - Fourth Edition
book

PostgreSQL 10 Administration Cookbook - Fourth Edition

by Simon Riggs, Gianni Ciolli
May 2018
Intermediate to advanced content levelIntermediate to advanced
576 pages
30h 25m
English
Packt Publishing
Content preview from PostgreSQL 10 Administration Cookbook - Fourth Edition

How to do it…

  1. You can write the following query:
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');
  1. You will get an output like the following:
-[ 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) ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PostgreSQL 13 Cookbook

PostgreSQL 13 Cookbook

Vallarapu Naga Avinash Kumar
PostgreSQL 9 Administration Cookbook - Second Edition

PostgreSQL 9 Administration Cookbook - Second Edition

Simon Riggs, GIANNI CIOLLI, Hannu Krosing, Gabriele Bartolini

Publisher Resources

ISBN: 9781788474924Supplemental Content