select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SYSTEM CATALOGS / STATISTICS VIEWS

pg_stat_activity

Read PG 18 manual ↗

The pg_stat_activity view will have one row per server process, showing information related to the current activity of that process.

Kind
Statistics views
Columns in this snapshot
22
Definition source
English manual

Columns 22

ColumnTypeDescription / reference
datidoidOID of the database this backend is connected to
datnamenameName of the database this backend is connected to
pidintegerProcess ID of this backend
leader_pidintegerProcess ID of the parallel group leader if this process is a parallel query worker, or process ID of the leader apply worker if this process is a parallel apply worker. NULL indicates that this process is a parallel group leader or leader apply worker, or does not participate in any parallel operation.
usesysidoidOID of the user logged into this backend
usenamenameName of the user logged into this backend
application_nametextName of the application that is connected to this backend
client_addrinetIP address of the client connected to this backend. If this field is null, it indicates either that the client is connected via a Unix socket on the server machine or that this is an internal process such as autovacuum.
client_hostnametextHost name of the connected client, as reported by a reverse DNS lookup of client_addr. This field will only be non-null for IP connections, and only when log_hostname is enabled.
client_portintegerTCP port number that the client is using for communication with this backend, or -1 if a Unix socket is used. If this field is null, it indicates that this is an internal server process.
backend_starttimestamp with time zoneTime when this process was started. For client backends, this is the time the client connected to the server.
xact_starttimestamp with time zoneTime when this process' current transaction was started, or null if no transaction is active. If the current query is the first of its transaction, this column is equal to the query_start column.
query_starttimestamp with time zoneTime when the currently active query was started, or if state is not active, when the last query was started
state_changetimestamp with time zoneTime when the state was last changed
wait_event_typetextThe type of event for which the backend is waiting, if any; otherwise NULL. See Table 27.4.
wait_eventtextWait event name if backend is currently waiting, otherwise NULL. See Table 27.5 through Table 27.13.
statetextCurrent overall state of this backend. Possible values are:
backend_xidxidTop-level transaction identifier of this backend, if any; see Section 67.1.
backend_xminxidThe current backend's xmin horizon.
query_idbigintIdentifier of this backend's most recent query. If state is active this field shows the identifier of the currently executing query. In all other states, it shows the identifier of last query that was executed. Query identifiers are not computed by default so this field will be null unless compute_query_id parameter is enabled or a third-party module that computes query identifiers is configured.
querytextText of this backend's most recent query. If state is active this field shows the currently executing query. In all other states, it shows the last query that was executed. By default the query text is truncated at 1024 bytes; this value can be changed via the parameter track_activity_query_size.
backend_typetextType of current backend. Possible types are autovacuum launcher, autovacuum worker, logical replication launcher, logical replication worker, parallel worker, background writer, client backend, checkpointer, archiver, standalone backend, startup, walreceiver, walsender, walwriter and walsummarizer. In addition, background workers registered by extensions may have additional types.
Column history across versions
Column9.09.19.29.39.49.59.61011121314151617181920
datid
datname
pid··
usesysid
usename
application_name
client_addr
client_hostname·
client_port
backend_start
xact_start
query_start
state_change··
wait_event_type······
wait_event······
state··
backend_xid····
backend_xmin····
query··
backend_type·······
leader_pid··········
query_id···········
procpid················
waiting············
current_query················
Version history 14
  1. PG 19 → 20changed
  2. PG 17 → 18changed
  3. PG 16 → 17changed
  4. PG 15 → 16changed
  5. PG 13 → 14changed
  6. PG 12 → 13changed
  7. PG 11 → 12changed
  8. PG 10 → 11changed
  9. PG 9.6 → 10changed
  10. PG 9.5 → 9.6changed
  11. PG 9.4 → 9.5changed
  12. PG 9.3 → 9.4changed
  13. PG 9.1 → 9.2changed
  14. PG 9.0 → 9.1changed

Definition snapshot: english-manuals:c56519f4bce8c09bdd602ce4c1c… · English manual source