PG_STAT_ACTIVITY
PG_STAT_ACTIVITY displays information about the current user's queries. The columns save information about the last query.
Name |
Type |
Description |
---|---|---|
datid |
oid |
OID of the database that the user session connects to in the backend. |
datname |
name |
Name of the database that the user session connects to in the backend. |
pid |
bigint |
ID of the backend thread. |
sessionid |
bigint |
Session ID. |
usesysid |
oid |
OID of the user logged in to the backend. |
usename |
name |
Name of the user logged in to the backend. |
application_name |
text |
Name of the application connected to the backend. |
client_addr |
inet |
IP address of the client connected to the backend. If this column is NULL, it indicates either the client is connected through a Unix socket on the server or 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 column will be non-null only for IP connections and only when log_hostname is enabled. |
client_port |
integer |
TCP port number that the client uses for communication with the backend (–1 if a Unix socket is used) |
backend_start |
timestamp with time zone |
Time when this session was started, that is, when the client connected to the server. |
xact_start |
timestamp with time zone |
Time when the current active transaction was started (NULL if no transaction is active). If the current query is the first of its transaction, the value of this column is the same as that of the query_start column. |
query_start |
timestamp with time zone |
Time when the current active query was started, or time when the last query was started if the value of state is not active. For a stored procedure, function, or package, the first query time is displayed and does not change with the running of statements in the stored procedure. |
state_change |
timestamp with time zone |
Time when state was last modified. |
waiting |
Boolean |
Whether the backend is currently waiting for a lock. If yes, the value is true. |
enqueue |
text |
Unsupported currently. |
state |
text |
Overall status of the backend. The value must be one of the following:
NOTE:
Common users can view their own session status only. The state information of other accounts is empty. For example, after user judy is connected to the database, the state information of user joe and the initial user omm in pg_stat_activity is empty. SELECT datname, usename, usesysid, state,pid FROM pg_stat_activity; datname | usename | usesysid | state | pid ----------+---------+----------+--------+----------------- testdb | omm | 10 | | 139968752121616 testdb | omm | 10 | | 139968903116560 db_tpcc | judy | 16398 | active | 139968391403280 testdb | omm | 10 | | 139968643069712 testdb | omm | 10 | | 139968680818448 testdb | joe | 16390 | | 139968563377936 (6 rows) |
resource_pool |
name |
Resource pool used by the user. |
query_id |
bigint |
ID of a query. |
query |
text |
Latest query at the backend. If the value of state is active, this column shows the ongoing query. In all other states, it shows the last query that was executed. |
connection_info |
text |
A string in JSON format recording the driver type, driver version, driver deployment path, and process owner of the connected database. For details, see the GUC parameter connection_info. |
unique_sql_id |
bigint |
Unique SQL statement ID. |
trace_id |
text |
Driver-specific trace ID, which is associated with an application request. |
top_xid |
xid |
Top-level transaction ID of a transaction. |
current_xid |
xid |
Current transaction ID of a transaction. |
xlog_quantity |
bigint |
Amount of Xlogs currently used by a transaction, in bytes. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot