How to Optimize COUNT(id) Full Table Scan

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

Original topic: COUNT(id) 进行了全表扫描怎么优化

| username: TiDBer_lVKhiLUB

【TiDB Usage Environment】Production Environment
【TiDB Version】
【Reproduction Path】What operations were performed when the issue occurred
【Encountered Issue: Problem Phenomenon and Impact】40 million data volume, count(id), takes 2 seconds
【Resource Configuration】
【Attachment: Screenshot/Log/Monitoring】

| username: h5n1 | Original post link

Index full scan, the optimizer has already optimized it.

| username: TiDBer_lVKhiLUB | Original post link

40 million data entries, count(id), takes 2 seconds.

| username: 胡杨树旁 | Original post link

The index has already been used.

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

Isn’t this using the ID index? I can only say that 40 million records are indeed quite a lot… Why not use TiFlash?

| username: system | Original post link

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