Checking which queries are active or blocked
Here, we will show you how to find out whether a query is running or waiting for another query.
Getting ready
Using the predefined (default) pg_monitor
role, you will have full access to monitoring information.
How to do it…
Follow these steps to check if a query is waiting for another query:
- Run the following query:
SELECT datname, usename, wait_event_type, wait_event, backend_type, query FROM pg_stat_activity WHERE wait_event_type IS NOT NULL AND wait_event_type NOT IN ('Activity', 'Client');
- You will receive the following output:
-[ RECORD 1 ]---+----------------- datname | postgres usename | gianni wait_event_type | Lock wait_event | relation backend_type | client backend query ...