In Hologres V2.0 and later, the PG_STAT_ACTIVITY view is upgraded to the HG_STAT_ACTIVITY view. The HG_STAT_ACTIVITY view is an extension of the PG_STAT_ACTIVITY view. You can use the HG_STAT_ACTIVITY view to query more detailed runtime information about active SQL queries. For example, you can query the query ID, query engine, and resource consumption information. This helps you diagnose issues of active queries.
Query the HG_STAT_ACTIVITY (PG_STAT_ACTIVITY) view
You can execute the following statements to query the runtime information about SQL queries on a Hologres instance. You can also use other management tools that are compatible with PostgreSQL to query the runtime information about SQL queries based on the PG_STAT_ACTIVITY view.
--Recommended syntax for V2.0 and later
SELECT * FROM HG_STAT_ACTIVITY;
-- Syntax for Hologres V1.3 and earlier
SELECT * FROM PG_STAT_ACTIVITY;The following table describes the fields in the HG_STAT_ACTIVITY view.
Field | Description | Supported by the HG_STAT_ACTIVITY view | Supported by the PG_STAT_ACTIVITY view |
datid | The object identifier (OID) of the connected database at the Hologres backend. | Supported | Supported |
datname | The name of the connected database at the Hologres backend. | Supported | Supported |
pid | The ID of the process at the Hologres backend. | Supported | Supported |
query_id | The ID of the current SQL statement. One SQL statement corresponds to one query_id. | Supported | Not supported |
transaction_id | The ID of the transaction to which the current SQL statement belongs. A transaction may contain multiple SQL statements. | Supported | Not supported |
usesysid | The system identifier of the user in the current active session. | Supported | Supported |
usename | The username that is used to create the current connection. | Supported | Supported |
application_name | The type of the application on the client. Common application types:
For other applications, we recommend that you explicitly specify the | Supported | Supported |
running_info | The status of an SQL query during the query execution process. The value is in the JSON format. This field contains the following subfields:
| Supported | Not supported |
extend_info | Extended information such as the resource consumption during the SQL query execution. The value is in the JSON format. This field contains the following subfields:
Note The be_lock_waiters subfield is valid for the backend lock, not the frontend lock. For more information about how to troubleshoot lock issues, see Locks and lock troubleshooting. | Supported | Not supported |
state | The status of the connection. Valid values:
| Supported | Supported |
query_start | The time when the SQL query starts to be executed. If the value of state for the current SQL query is not active, the start time of the previous SQL query is used. | Supported | Supported |
client_addr | The IP address of the client. The displayed IP address may have been resolved and may not be the actual IP address of the client. | Supported | Supported |
client_hostname | The hostname of the client. | Supported | Supported |
client_port | The port number of the client. | Supported | Supported |
backend_start | The start time of the backend process. You do not need to pay much attention to this field of Hologres. | Supported | Supported |
xact_start | The start time of the current transaction of the process.
You do not need to pay much attention to this field of Hologres. | Supported | Supported |
state_change | The time when the state of the connection was last changed. You do not need to pay much attention to this field of Hologres. | Supported | Supported |
wait_event_type | The type of the event for which the backend is waiting for. If the backend is waiting for no event, the value of this field is NULL. Valid values:
| Supported | Supported |
wait_event | The name of the event for which the backend is waiting. If the backend is waiting for no event, the value of this field is NULL. | Supported | Supported |
backend_xid | The identifier of the top-level transaction at the Hologres backend. | Supported | Supported |
backend_xmin | The xmin scope at the backend. | Supported | Supported |
query | The last query that was run at the backend. If the value of the state field is | Supported | Supported |
backend_type | The type of the backend. Supported types include autovacuum launcher, autovacuum worker, logical replication launcher, logical replication worker, parallel worker, background writer, client backend, checkpointer, startup, walreceiver, walsender, and walwriter. Backend execution components such as PQE are also supported. Note Take note of the | Supported | Supported |