HG_STAT_ACTIVITY (PG_STAT_ACTIVITY) view

更新时间:
复制 MD 格式

Starting in Hologres V2.0, the PG_STAT_ACTIVITY view is upgraded to HG_STAT_ACTIVITY. As an extension of the PG_STAT_ACTIVITY view, HG_STAT_ACTIVITY provides more detailed runtime information for an active SQL query, such as the query ID, query engine, and resource consumption. This information improves active query diagnostics.

Note

If you are using an instance with virtual warehouses, this view shows active queries only for the virtual warehouse to which you are currently connected. You cannot query active queries in other virtual warehouses.

Querying the HG_STAT_ACTIVITY (PG_STAT_ACTIVITY) view

You can run the following commands to view query runtime information. PostgreSQL-compatible management tools can still query PG_STAT_ACTIVITY to obtain SQL runtime information.

-- Recommended for V2.0 and later
SELECT *  FROM HG_STAT_ACTIVITY;

-- For V1.3 and earlier
SELECT *  FROM PG_STAT_ACTIVITY;

The following table describes the fields in the HG_STAT_ACTIVITY view.

Field

Description

HG_STAT_ACTIVITY support

PG_STAT_ACTIVITY support

datid

The object identifier (OID) of the database to which the Hologres backend is connected.

Supported

Supported

datname

The name of the database to which the Hologres backend is connected.

Supported

Supported

pid

The process ID of the Hologres backend.

Supported

Supported

query_id

A unique ID for the currently executing SQL query.

Supported

Not supported

transaction_id

The ID of the transaction to which the current SQL query belongs. A transaction can contain multiple SQL queries.

Supported

Not supported

usesysid

The system ID of the user in the current active session.

Supported

Supported

usename

The username for the current connection.

Supported

Supported

application_name

The name of the client application.

Common application names include:

  • Realtime Compute for Apache Flink (VVR version): {client_version}_ververica-connector-hologres.

  • Apache Flink: {client_version}_hologres-connector-flink.

  • DataWorks Data Integration for batch synchronization reading from Hologres: datax_{jobId}.

  • DataWorks Data Integration for batch synchronization writing to Hologres: {client_version}_datax_{jobId}.

  • DataWorks Data Integration for real-time synchronization: {client_version}_streamx_{jobId}.

  • HoloWeb: holoweb.

  • Accessing Hologres from MaxCompute by using a foreign table: MaxCompute.

  • A process initiated by Holo Client to read a Hologres binary log: holo_client_replication. The query content is not displayed for this type of task.

For other applications, we recommend that you explicitly specify the application_name in the connection string.

Supported

Supported

running_info

Contains information about the SQL execution process in JSON format. Subfields include:

  • current_resource

    This field is populated only for queries that run exclusively on Serverless resources.

  • current_stage

    • stage_name<PARSE|OPTIMIZE|QUEUE|START|EXECUTE|FINISH>:

      • PARSE: Parsing the SQL query.

        Note

        If a query is in the PARSE stage, the engine type cannot be displayed.

      • OPTIMIZE: Generating an execution plan.

      • QUEUE: Queuing for resources.

      • START: Starting the query.

      • EXECUTE: Executing the query.

      • FINISH: Finishing execution.

    • stage_duration_ms: The time elapsed in the current stage, in milliseconds.

    • queue_time_ms: The queuing duration in milliseconds. This field is returned only for Serverless queries.

    • serverless_allocated_cores: The amount of allocated Serverless resources, in compute units (CUs). This field is returned only for Serverless queries.

    • serverless_allocated_workers: The number of allocated Serverless workers. This field is returned only for Serverless queries.

  • engine_type: The query engine for the current query.

    • {HQE}: The Hologres engine.

    • {HQE,PQE}: The SQL query uses PQE.

    • {PG}: A system SQL query. No action is required.

    • {SDK} or {FixedQE}: A Fixed Plan SQL query.

      Note

      In Hologres versions earlier than V2.2, the engine_type for Fixed Plan SQL was {SDK}. Starting from Hologres V2.2, the engine_type is changed from {SDK} to {FixedQE}.

    • {HQE,SQE}: An SQL query on a MaxCompute foreign table with direct read disabled.

    • {HQE,HiveQE}: An SQL query on an OSS foreign table with direct read disabled.

    • {HQE,SQE,HiveQE}: An SQL query on a foreign table with direct read disabled.

  • fe_id: The ID of the FE node.

  • warehouse_id: If the instance uses virtual warehouses, this field indicates the ID of the virtual warehouse.

Supported

Not supported

extend_info

Contains extended information about resource consumption during SQL execution in JSON format. Subfields include:

  • total_cpu_max_time_ms: The cumulative CPU time consumed by the SQL query, in milliseconds.

  • total_mem_max_bytes: The sum of the peak memory usage of each operator in the query, in bytes.

  • scanned_rows: The total number of rows read by the query.

  • affected_rows: The number of rows affected by the DML statement.

  • be_lock_waiters: If the current query holds a lock that blocks other queries, this field lists the query IDs of the waiting queries.

Note

be_lock_waiters tracks backend locks, not frontend locks. For information about lock troubleshooting, see Locks and lock troubleshooting.

Supported

Not supported

state

The state of the connection. Common states include:

  • active: The connection is active.

  • idle: The connection is idle.

  • idle in transaction: The connection is idle within a long-running transaction.

  • idle in transaction (Aborted): The connection is idle within a failed transaction.

  • \N: The state is null. This indicates a non-user process, typically a background system maintenance process, which you can ignore.

Supported

Supported

query_start

The time when the query started. If the state is not active, this is the start time of the most recent query.

Supported

Supported

client_addr

The IP address of the client.

This may be a resolved address, not the original source IP address.

Supported

Supported

client_hostname

The hostname of the client.

Supported

Supported

client_port

The port of the client.

Supported

Supported

backend_start

The time when the backend process started.

This field is typically not relevant in Hologres.

Supported

Supported

xact_start

The start time of the process's current transaction.

  • This is null if no transaction is active.

  • If the current query is the first transaction of the process, this column is the same as query_start.

This field is typically not relevant in Hologres.

Supported

Supported

state_change

The time when the connection state (state) was last changed.

This field is typically not relevant in Hologres.

Supported

Supported

wait_event_type

The type of event the backend is waiting for. NULL if not waiting. Possible values include:

  • LWLock: The backend is waiting for a lightweight lock.

  • Lock: The backend is waiting for a heavyweight lock. The wait_event field identifies the type of lock.

  • BufferPin: The server process is waiting to access a data buffer, and no other process is currently inspecting that buffer.

  • Activity: The server process is idle. This value is used for system processes that are waiting for activity in their main processing loop.

  • Extension: The server process is waiting for activity in an extension module.

  • Client: The server process is waiting for communication from the client.

  • PC: The server process is waiting for some activity from another process in the server.

  • Timeout: The server process is waiting for a timeout to expire.

  • IO: The server process is waiting for an I/O operation to complete.

Supported

Supported

wait_event

The name of the wait event, if the backend is waiting. NULL otherwise.

Supported

Supported

backend_xid

The top-level transaction identifier of the Hologres backend.

Supported

Supported

backend_xmin

The current backend's xmin horizon.

Supported

Supported

query

The text of the backend's most recent query. If the state is active, this field shows the currently executing query. Otherwise, it shows the last query that was executed.

Supported

Supported

backend_type

The type of the current backend. Possible types are autovacuum launcher, autovacuum worker, logical replication launcher, logical replication worker, parallel worker, background writer, client backend, checkpointer, startup, walreceiver, walsender, and walwriter. This also includes backend execution components, such as PQE.

Note

Pay attention to the client backend type, which represents a connection from your application.

Supported

Supported