Statistics Information Not Automatically Collected

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

Original topic: 统计信息未自动收集

| username: chenhanneu

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Problem Phenomenon and Impact]
The default parameters for statistics collection have not been adjusted, and the health of some tables is 0, yet statistics are still not being collected automatically.
Some tables do collect statistics automatically.
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]

| username: WalterWj | Original post link

Is the table that hasn’t been collected either very small in data volume or empty?

| username: redgame | Original post link

Can you see any anomalies in the logs related to statistics collection?

| username: wakaka | Original post link

Are those tables frequently subjected to large batches of DML or being truncated?

| username: chenhanneu | Original post link

There are about 1 million pieces of data, and it won’t truncate. It was synchronized from upstream MySQL using DM, and manual collection has never been done. No analyze-related errors were found in the logs.

| username: TiDBer_vfJBUcxl | Original post link

Check if this is useful:

| username: WalterWj | Original post link

Is the data continuously coming in? I remember that TiDB has a mechanism for automatically collecting statistics: it won’t collect for small or empty tables; also, if the table has continuous writes, it won’t collect either. I personally recommend you manually collect statistics for tables with a health score below 0.7.

| username: chenhanneu | Original post link

Basically, there are always data changes. I collected them manually first, and then observed whether it would be automatic when it reaches the threshold.