Hello, I’m DocuDroid!
Submitting feedback
Thank you for rating our AI Search!
We would be grateful if you could share your thoughts so we can improve our AI Search for you and other readers.
GitHub

pg_stat_activity

The pg_stat_activity view shows one row per server process with details about the associated user session and query. The columns that report data on the current query are available unless the stats_command_string parameter 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.

The maximum length of the query text string stored in the query column can be controlled with the server configuration parameter track_activity_query_size.

Column Type References Description

datid

oid

pg_database.oid

Database OID

datname

name

 — 

Database name

pid

integer

 — 

Process ID of this backend

sess_id

integer

 — 

Session ID

usesysid

oid

pg_authid.oid

OID of the user logged into this backend

usename

name

 — 

Name of the user logged into this backend

application_name

text

 — 

Name of the application that is connected to this backend

client_addr

inet

 — 

IP 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_hostname

text

 — 

Host name of the connected client, as reported by a reverse DNS lookup of client_addr. This field will only be non-null for remote connections, and only when log_hostname is enabled

client_port

integer

 — 

TCP port number that the client is using for communication with this backend, or -1 if a Unix socket is used

backend_start

timestamptz

 — 

Time the backend process was started

xact_start

timestamptz

 — 

Transaction start time

query_start

timestamptz

 — 

Time query began execution

state_change

timestamptz

 — 

Time when the state value was last changed

waiting

boolean

 — 

true if waiting on a lock, false if not waiting

state

text

 — 

Current overall state of this backend. Possible values are:

  • active — the backend is running 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 running 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 running a fast-path function.

  • disabled — this state is reported if track_activities is deactivated in this backend.

backend_xid

xid

 — 

Top-level transaction identifier of this backend, if any

backend_xmin

xid

 — 

The current backend’s xmin horizon

query

text

 — 

Text of this backend’s most recent query. If state is active, this field shows the currently running query. In all other states, it shows the last query that was run

waiting_reason

text

 — 

Reason the server process is waiting. The value can be: lock, replication, or resgroup

rsgid

oid

pg_resgroup.oid

Resource group OID or 0

rsgname

text

pg_resgroup.rsgname

Resource group name or unknown

rsgqueueduration

interval

 — 

For a queued query, the total time the query has been queued