How Do I Locate the SQL Statements with High CPU Usage?
Symptom
The CPU usage remains high.
Possible Causes
During SQL statement execution, a thread occupies excessive CPU resources.
Handling Procedure
- Find a GaussDB process and confirm the process ID and the corresponding DN port number, for example, 32089.
- Run the following command to check the CPU usage of each thread in the process:
1 2 3 4
ps H -eo pid,tid,pcpu | sort -n -k 3 | grep 32089, 32089 48369 81.9 32089 41335 82.3 32089 10596 85.6
- Run the preceding command for multiple times to query the thread that keeps occupying excessive CPU resources and connect to the DN. Then run the following command:
1select query_id from pg_thread_wait_status where lwtid = 10596;
The value of query_id is 95174458.
- Run the following command to query the corresponding SQL statement:
1select * from pg_stat_activity where query_id = 95174458;
Last Article: Table Bloating Causes Slow SQL Query and Failed Data Loading on the GUI
Next Article: Memory Overflow Occurs in a Cluster
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.