Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

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
Help Center/ GaussDB(DWS)/ Troubleshooting/ Cluster Performance/ SQL Execution Is Slow with Low Performance and Sometimes Does Not End After a Long Period of Time

SQL Execution Is Slow with Low Performance and Sometimes Does Not End After a Long Period of Time

Updated on 2025-01-06 GMT+08:00

Symptom

The SQL execution is slow with low performance and sometimes does not end after a long period of time.

Possible Causes

Analyze the causes of slow SQL execution from the following aspects:

  1. Run the EXPLAIN command to view the SQL execution plan and determine whether to optimize the SQL statements based on the plan.
  2. Check whether the query is blocked. If the query is blocked, the statement execution takes a long time. In this case, you can forcibly terminate the abnormal sessions.
  3. Review and modify the table definitions. Select an appropriate distribution key to avoid data skew.
  4. Check whether the SQL statements use functions that do not support pushdown. You are advised to use the syntax or function that supports pushdown.
  5. Run the VACUUM FULL and ANALYZE commands periodically to reclaim the disk space occupied by updated or deleted data.
  6. Check whether the table has an index. You are advised to re-create the index regularly.

    After multiple deletion operations are performed on the database, the index key on the index page will be deleted, causing index expansion. Re-creating the index regularly can improve the query efficiency.

  7. Optimize services and analyze whether large tables can be divided.

Handling Procedure

GaussDB(DWS) provides methods for analyzing and optimizing queries, as well as some common cases and error handling methods. For how to tune SQL performance, see GaussDB(DWS) Performance Tuning. For how to tune SQL performance, see " GaussDB(DWS) Performance Tuning" in the Data Warehouse Service (DWS) Developer Guide. Common problem locating methods are as follows:

  • Method 1: Periodically collect statistics on the table and optimize the table data.
    If you frequently run the INSERT statement to insert data into a table, you need to periodically run the ANALYZE statement on the table.
    1
    ANALYZE table_name;
    
    If you frequently run the DELETE statement to delete data from a table, you need to periodically run the VACUUM FULL statement on the table.
    1
    VACUUM FULL table_name;
    
    NOTE:

    Run the VACUUM FULL statement in an idle time window or when services are stopped.

    Query the table size. If the table size is large but only a small amount of data exists, run the VACUUM FULL command to reclaim the space.
    1
    2
    SELECT * FROM pg_size_pretty(pg_table_size('tablename'));
    VACUUM FULL table_name;
    

Method 2: Query information about running SQL statements in the PGXC_STAT_ACTIVITY view.

  1. Run the following command to view the information about the SQL statements that are not in the idle state:

    1
    SELECT pid,datname,usename,state,waiting,query FROM pgxc_stat_activity WHERE state <> 'idle';
    

  2. Run the following command to view blocked query statements:

    1
    SELECT pid,datname, usename, state,waiting,query FROM pgxc_stat_activity WHERE state <> 'idle' and waiting=true;
    

  3. Check whether the query statement is blocked.

    • If no blocking occurs, search for related service tables and rectify the fault according to Method 1.
    • If a statement is blocked, end the blocked statement based on the thread ID of the faulty session.
      1
      SELECT pg_terminate_backend(pid);
      

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback