How to use SQL scripts to count high CPU-consuming SQL on TiDB nodes

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

Original topic: 如何用sql脚本统计 tidb 节点上cpu 耗时高的SQL。

| username: TiDBer_rdb3y58G

How to count the SQL with high CPU time on the TiDB node? The cluster_statements_summary does not have relevant CPU statistics fields.
In the dashboard, in the top SQL section, you can select the TiDB server to see which SQLs consume CPU. How can I check this using an SQL script?

| username: awakening | Original post link

SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST