Querying the INFORMATION_SCHEMA.SLOW_QUERY table from different TiDB nodes yields inconsistent results

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

Original topic: 从不同的TIDB节点查询INFORMATION_SCHEMA.SLOW_QUERY表中数据,结果不一致

| username: Curiouser

TiDB version is 5.1.0
Question:
Whether using Navicat, mysql-cli, or Python’s MySQL module, querying the following SQL from the 4000 port of two TiDB nodes returns inconsistent results.
The SQL is:
SELECT
DB AS ‘Database’,
Query_time AS ‘Execution Time’,
Total_keys AS ‘Total Keys Scanned’,
CONCAT( ‘'’, Time ) AS ‘Execution Time’,
USER AS ‘User’,
HOST AS ‘Host’,
QUERY AS ‘SQL Query’
FROM
INFORMATION_SCHEMA.SLOW_QUERY
WHERE
Query_time >= ‘10’
AND DATE_SUB( ‘2022-09-21 11:36:37.628878’, INTERVAL 7 DAY ) <= ‘2022-09-21 11:36:37.628878’
ORDER BY
Query_time DESC
LIMIT 1000;

| username: Kongdom | Original post link

Yes, I suggest checking this table cluster_slow_query, which is the cluster slow query table.

| username: 啦啦啦啦啦 | Original post link

It is the expected behavior. SLOW_QUERY parses the slow query log files corresponding to each TiDB server node, and the CLUSTER_SLOW_QUERY table provides information related to slow queries from all nodes in the cluster.

| username: Curiouser | Original post link

Okay, thank you for answering the question.

| username: Curiouser | Original post link

Okay, thank you.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.