↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / System Catalogs

pg_stat_activity

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

English manual coverage begins with PostgreSQL 7.4. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

kind
statistics
lang
en
measured attributes
true
metadata release
18.6
runtime verified
false
source
english-manual

Definition PG 18

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

Catalog columns

ColumnTypeNullabilityDescription
datidoidNullableOID of the database this backend is connected to
datnamenameNullableName of the database this backend is connected to
pidintegerNullableProcess ID of this backend
leader_pidintegerNullableProcess 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.
usesysidoidNullableOID of the user logged into this backend
usenamenameNullableName of the user logged into this backend
application_nametextNullableName of the application that is connected to this backend
client_addrinetNullableIP 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_hostnametextNullableHost 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_portintegerNullableTCP 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 zoneNullableTime when this process was started. For client backends, this is the time the client connected to the server.
xact_starttimestamp with time zoneNullableTime 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 zoneNullableTime when the currently active query was started, or if state is not active, when the last query was started
state_changetimestamp with time zoneNullableTime when the state was last changed
wait_event_typetextNullableThe type of event for which the backend is waiting, if any; otherwise NULL. See Table 27.4.
wait_eventtextNullableWait event name if backend is currently waiting, otherwise NULL. See Table 27.5 through Table 27.13.
statetextNullableCurrent overall state of this backend. Possible values are: starting: The backend is in initial startup. Client authentication is performed during this phase. active: The backend is executing a query. idle: The backend is waiting for a new client command. idle in transaction: The backend is in a transaction, but is not currently executing a query. idle in transaction (aborted): This state is similar to idle in transaction, except one of the statements in the transaction caused an error. fastpath function call: The backend is executing a fast-path function. disabled: This state is reported if track_activities is disabled in this backend.
backend_xidxidNullableTop-level transaction identifier of this backend, if any; see Section 67.1.
backend_xminxidNullableThe current backend's xmin horizon.
query_idbigintNullableIdentifier 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.
querytextNullableText 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_typetextNullableType 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.

Compare versions

Complete source facts

documentation revision

{"inputs":[{"file":"monitoring-stats.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"a97e4aa05484b41cec1f4c9b0b9c5a083596a056982e5d5ba0db1dd8d49961fb","version":"18.7"},{"file":"monitoring-stats.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"1ddb6576fe569e029a1c776c82e7add6be8e4f41705bcd8f66f4347fe23372b6","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"}

runtime columns

datid, datname, pid, leader_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_id, query, backend_type

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · catalog-bilingual-repair:596c67af4af6f903ed566f224cc34aa4d1d582d6b690b41575031d33896e2440

Text language: en · catalog-bilingual-repair:596c67af4af6f903ed566f224cc34aa4d1d582d6b690b41575031d33896e2440