The view pg_stat_activity shows one row per server process and details about it associated user session and query. The columns that report data on the current query are available unless the parameter stats_command_string has been turned off. Furthermore, these columns are only visible if the user examining the view is a superuser or the same as the user owning the process being reported on.

Table 1. pg_catalog.pg_stat_activity

column type references description
datid oid pg_database.oid Database OID
datname name   Database name
procpid integer   Process ID of the server process
sess_id integer   Session ID
usesysid oid pg_authid.oid Role OID
usename name   Role name
current_query text   Current query that process is running
waiting boolean   True if waiting on a lock, false if not waiting
query_start timestamp with time zone   Time query began execution
backend_start timestamp with time zone   Time backend process was started
client_addr inet   Client address
client_port integer   Client port
application_name text   Client application name
xact_start timestamp with time zone   Transaction start time
waiting_resource boolean   True if waiting for resource allocation, false if not waiting