- pg_stat_activity
pg_stat_activity is a view that belongs to the postgresql catalog, it helps you to view the status of the queries that are in execution, the explanation of each column can be found in the postgresql manual The Statistics Collector section (I don't want to do a simply copy-paste, so see the official documentation).
Column | Type | Modifiers |
---|---|---|
datid | oid | |
datname | name | |
procpid | integer | |
usesysid | oid | |
usename | name | |
current_query | text | |
waiting | boolean | |
xact_start | timestamp with time zone | |
query_start | timestamp with time zone | |
backend_start | timestamp with time zone | |
client_addr | inet | |
client_port | integer |
SELECT * FROM pg_stat_activity;
If you want to view the queries that are stuck (usually due to a lock or simply waiting for I/O) you can execute the following query:
SELECT * FROM pg_stat_activity WHERE waiting = TRUE;