PG_STAT_ACTIVITY
PG_STAT_ACTIVITY displays information about the current user's queries. The columns save information about the last query. This view displays the table that is being cleared by the current worker. The columns are described as follows:
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 |
Backend thread ID. |
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 that either the client is connected via a UDS 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 only be non-null 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 |
Start time of the process when the client connects to the server. |
xact_start |
timestamp with time zone |
Time when the current transaction is 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 |
Start time of the active query. If state is not active, the start time of the previous query is queried. For a stored procedure, function, or package, the first query time is queried 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 |
Specifies whether the backend is currently waiting for a lock. If the backend is currently waiting for a lock, the value is true. |
enqueue |
text |
Unsupported currently. |
state |
text |
Overall status of this backend. Values are as follows:
|
resource_pool |
name |
Resource pool used by the user. |
query_id |
bigint |
ID of a query. |
query |
text |
Latest query at the backend. If 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 "connection_info" in "Configuring GUC Parameters > GUC Parameters > Connection and Authentication > Connection Settings" in Administrator Guide.) |
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. |
The running result is as follows:
gaussdb=# select * from pg_stat_activity where query ilike '%vacuum%' and query not like 'select%';
datid | datname | pid | sessionid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_st
art | xact_start | query_start | state_change | waiting | enqueue | state | resource_pool | que
ry_id | query | connection_info
| unique_sql_id | trace_id | top_xid | current_xid | xlog_quantity
-------+----------+-----------------+-----------------+----------+-----------+------------------+-------------+-----------------+-------------+-------------------
------------+-------------------------------+-------------------------------+-------------------------------+---------+---------+--------+---------------+--------
----------+---------------+---------------------------------------------------------------------------------------------------------------------------------------
----------------------+---------------+----------+---------+-------------+---------------
12912 | postgres | 140123447490304 | 140123447490304 | 10 | postgres | gsql | | | -1 | 2025-02-09 10:13:3
0.726384-05 | 2025-02-09 10:13:30.761649-05 | 2025-02-09 10:13:30.761649-05 | 2025-02-09 10:13:30.761654-05 | f | | active | default_pool | 3096224
743913390 | vacuum freeze | {"driver_name":"libpq","driver_version":"(GaussDB Kernel 505.2.1.SPC0100 build 1dc713e2) compiled at 2025-02-08 15:32:13 commit 10212
last mr 22203 debug"} | 2396388490 | | 0 | 0 | 0
(1 row)
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