Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 请问可否查看 SQL 语句访问了哪些region吗?
Background:
A slow SQL with a specific id
Full table group by takes 3 seconds
SELECT col_id, sum(money) as money FROM t where logtime >= ‘2022-08-23’ group by col_id;
18 rows in set (3.20 sec)
id 127 is slow:
SELECT col_id, sum(money) as money FROM t WHERE col_id = 127 AND logtime >= ‘2022-08-23’ group by col_id;
1 row in set (59.00 sec)
Rewritten query is even slower
select * from (SELECT col_id, sum(money) as money FROM t where logtime >= ‘2022-08-23’ group by col_id) as tmp_a where tmp_a.col_id = 127;
1 row in set (1 min 11.29 sec)
id 100 is fast:
SELECT col_id, sum(money) as money FROM t WHERE col_id = 100 AND logtime >= ‘2022-08-23’ group by col_id;
1 row in set (3.40 sec)
Table t is a partitioned table, and the number of entries with id 100 is more than that with id 127. There is an index on col_id and the query utilizes this index. This cluster does not have TiFlash or similar components, only pd, tidb, and tikv.
Therefore, I suspect it might be a hardware performance issue and want to check which store the region with col_id = 127 is distributed on.