pg_stat_activity

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

columntypereferencesdescription
datidoidpg_database.oidDatabase OID
datnamename Database name
procpidinteger Process ID of the server process
sess_idinteger Session ID
usesysidoidpg_authid.oidRole OID
usenamename Role name
current_querytext Current query that process is running
waitingboolean True if waiting on a lock, false if not waiting
query_starttimestamp with time zone Time query began execution
backend_starttimestamp with time zone Time backend process was started
client_addrinet Client address
client_portinteger Client port
application_nametext Client application name
xact_starttimestamp with time zone Transaction start time
waiting_resourceboolean True if waiting for resource allocation, false if not waiting