Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 手动analyze table 耗时过长

I have a large table here, and manually analyzing it took 16096.221 seconds. Is there any way to optimize this?
Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 手动analyze table 耗时过长
I have a large table here, and manually analyzing it took 16096.221 seconds. Is there any way to optimize this?
Which version of TiDB is it? How large is the table data? Is this table a partitioned table?
With tens of billions of data, not partitioning it might actually be slower if partitioned.
I want to know if this analyze can be executed incrementally, or executed in the background like DDL, because it takes so long to complete. If the connection is lost due to network reasons, will it cause the previous execution to be wasted?
Refer to here: 统计信息简介 | PingCAP 文档中心
I think for particularly large tables, data should be collected proportionally. For example, WITH 0.1 SAMPLERATE only collects 10% of the data.
Additionally, I suggest modifying the concurrency of analyze. Increase it appropriately without affecting production applications.
For large tables with frequent data additions and deletions, slow optimization is normal. If it were faster, it could impact performance.
When analyzing, adding a sampling ratio will certainly affect the optimizer’s choice of algorithm.
You can increase the ANALYZE concurrency and allocate more resources to the analyze operation. Reference link:
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.