Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Real-time TopSQL

Updated on 2022-08-16 GMT+08:00

You can query real-time Top SQL in real-time resource monitoring views at different levels. The real-time resource monitoring view records the resource usage (including memory, disk, CPU time, and I/O) and performance alarm information during job running.

The following table describes the external interfaces of the real-time views.

Table 1 Real-time resource monitoring views

Level

Monitored Node

View

Query level/perf level

Current CN

GS_WLM_SESSION_STATISTICS

All CNs

PGXC_WLM_SESSION_STATISTICS

Operator level

Current CN

GS_WLM_OPERATOR_STATISTICS

All CNs

PGXC_WLM_OPERATOR_STATISTICS

NOTE:
  • The view level is determined by the resource monitoring level, that is, the resource_track_level configuration.
  • The perf and operator levels affect the values of the query_plan and warning columns in GS_WLM_SESSION_STATISTICS/PGXC_WLM_SESSION_INFO. For details, see SQL Self-Diagnosis.
  • Prefixes gs and pgxc indicate views showing single CN information and those showing cluster information, respectively. Common users can log in to a CN in the cluster to query only views with the gs prefix.
  • When you query this type of views, there will be network latency, because the views obtain resource usage in real time.
  • If instance fault occurs, some SQL statement information may fail to be recorded in real-time resource monitoring views.
  • SQL statements are recorded in real-time resource monitoring views as follows:
    • DDL statements are not recorded, such as the execution of CREATE, ALTER, DROP, GRANT, REVOKE, and VACUUM statements.
    • DML statements are recorded, including:
      • the execution of SELECT, INSERT, UPDATE, and DELETE
      • the execution of EXPLAIN ANALYZE and EXPLAIN PERFORMANCE
      • the use of a query-level/perf-level view, which also supports the CREATE TABLE AS syntax.
    • Statements in functions and stored procedures and statements used for calling functions and stored procedures are recorded. Statements in loop bodies (if any) of functions and stored procedures are not recorded.
    • Statements in anonymous blocks are not recorded.
    • Statements in transaction blocks are recorded. Statements in loop bodies (if any) of transaction blocks are not recorded.
    • Cursor statements are recorded.
    • Jobs in a redistribution process are not monitored.

Prerequisites

  • The GUC parameter enable_resource_track is set to on. The default value is on.
  • The GUC parameter resource_track_level is set to query, perf, or operator. The default value is query.
  • Job monitoring rules are as follows:
    • Jobs whose execution cost estimated by the optimizer is greater than or equal to resource_track_cost.
    • Long query jobs
  • If the Cgroups function is properly loaded, you can run the gs_cgroup -P command to view information about Cgroups.

In the preceding prerequisites, enable_resource_track is a system-level parameter that specifies whether to enable resource monitoring. resource_track_level is a session-level parameter. You can set the resource monitoring level of a session as needed. The following table describes the values of the two parameters.

Table 2 Setting the resource monitoring level to collect statistics

enable_resource_track

resource_track_level

Query-Level Information

Operator-Level Information

on(default)

none

Not collected

Not collected

query(default)

Collected

Not collected

perf

Collected

Not collected

operator

Collected

Collected

off

none/query/operator

Not collected

Not collected

Procedure

  1. Query for the real-time CPU information in the gs_session_cpu_statistics view.

    1
    SELECT * FROM gs_session_cpu_statistics;
    

  2. Query for the real-time memory information in the gs_session_memory_statistics view.

    1
    SELECT * FROM gs_session_memory_statistics;
    

  3. Query for the real-time resource information about the current CN in the gs_wlm_session_statistics view.

    1
    SELECT * FROM gs_wlm_session_statistics;
    

  4. Query for the real-time resource information about all CNs in the pgxc_wlm_session_statistics view.

    1
    SELECT * FROM pgxc_wlm_session_statistics;
    

  5. Query for the real-time resource information about job operators on the current CN in the gs_wlm_operator_statistics view.

    1
    SELECT * FROM gs_wlm_operator_statistics;
    

  6. Query for the real-time resource information about job operators on all CNs in the pgxc_wlm_operator_statistics view.

    1
    SELECT * FROM pgxc_wlm_operator_statistics;
    

  7. Query for the load management information about the jobs executed by the current user in the PG_SESSION_WLMSTAT view.

    1
    SELECT * FROM pg_session_wlmstat;
    

  8. Query the job execution status of the current user on each CN in the pgxc_wlm_workload_records view (this view is available when the dynamic load function is enabled, that is, enable_dynamic_workload is set to on).

    1
    SELECT * FROM pgxc_wlm_workload_records;
    

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback