How to Quickly Identify and Troubleshoot High CPU Usage on a TiDB Machine: Step-by-Step Guide

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TIDB某个机器CPU过高,怎么快速定位问题,步骤是怎样的

| username: TiDBer_bOR8eMEn

Are there any good methods to locate and troubleshoot step by step when the CPU of a certain TiDB machine is too high? Seeking advice from experts.

| username: tidb菜鸟一只 | Original post link

Mixed deployment? First, use the top command to check which component is consuming high CPU… It’s usually caused by large SQL queries.

| username: TiDBer_bOR8eMEn | Original post link

How to check if a large SQL is being executed

| username: TiDBer_bOR8eMEn | Original post link

Can TiDB view executed SQL?

| username: zhaokede | Original post link

Look at hotspots and slow SQL, analyze them one by one.

| username: Miracle | Original post link

Check the TiDB logs and search for any expensive SQL. You can also take a look at the slow logs.

| username: Miracle | Original post link

You can see the currently executing SQL by using the SHOW PROCESSLIST command.

| username: DBAER | Original post link

Check the top SQL on the dashboard.

| username: kkpeter | Original post link

Dashboard, sort the execution time of SQL statement analysis.

| username: TiDBer_QYr0vohO | Original post link

Check the dashboard for top SQL and slow SQL.

| username: TIDB-Learner | Original post link

  1. Through TiDB’s built-in monitoring
  2. Using the operating system’s built-in commands.
| username: tidb菜鸟一只 | Original post link

Take a look in the dashboard.

| username: zhanggame1 | Original post link

The MySQL client connects to a server with high CPU usage.
To observe by memory:

select * from INFORMATION_SCHEMA.PROCESSLIST t
where t.COMMAND<>'Sleep'
order by mem desc;

To observe by execution time:

select * from INFORMATION_SCHEMA.PROCESSLIST t
where t.COMMAND<>'Sleep'
order by time desc;
| username: yulei7633 | Original post link

You can check the slow queries on the dashboard to get an idea.

| username: 有猫万事足 | Original post link

TopSQL

This interface is quite effective in dealing with the situation of uneven load on a single TiDB. You can give it a try.

| username: yytest | Original post link

Use the top command to check the operating system process usage.

| username: 小于同学 | Original post link

Take a look at top SQL

| username: TiDBer_bOR8eMEn | Original post link

I don’t have TOP SQL in my tidbiDASH.

| username: TiDBer_RjzUpGDL | Original post link

Check the slow SQL on the dashboard.

| username: 健康的腰间盘 | Original post link

Check the dashboard for slow SQL and resource monitoring.