Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 查询元数据information_schema.columns很慢
【TiDB Usage Environment】Production Environment
【TiDB Version】5.2.2
【Encountered Problem】
Querying the metadata columns table is very slow
【Reproduction Path】
None
【Problem Phenomenon and Impact】
No bottleneck in machine resource performance, querying the columns table is very slow
【Attachments】
Please provide the version information of each component, such as cdc/tikv, which can be obtained by executing cdc version/tikv-server --version.
information_schema.columns
is a virtual table. When queried, TiDB dynamically constructs this table based on the data. If the data volume is large, it will indeed be slow.
Is it normal for the data volume shown in the picture to be this slow? Are there any ways to optimize it?
Why does executing this statement result in warnings?
1111.log (4.1 MB)
Uploaded trace format=‘row’ select count(*) from information_schema.columns where table_schema=‘wms_core’; The result is in the attachment.
I found a region ID with 4680 occurrences. This region contains dozens of tables and indexes, all with very small amounts of data, so it feels like a merged region. I wonder if the slow metadata query is related to this?
It feels like a bug. In version 5.2.3, there are over 40,000 rows in the columns trace result, but there isn’t a single region request. This bug is fixed in version 5.2.4.