Was the parameter value tidb_analyze_version=2 introduced after version v5.3.0 to fix the issues in the previous version?

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

Original topic: 在v5.3.0版本之后引入了tidb_analyze_version=2的参数值,请问这个是修复了上个版本的故障吗?

| username: TiDBer_HzlduICa

[TiDB Usage Environment] Production Environment
[TiDB Version] TiDB 5.1.4
[Reproduction Path] Tested the execution plan of an SQL in TiDB 5.1.4 and upgraded to TiDB 7.1.0, setting tidb_analyze_version=2, and tested the execution plan of the same SQL.
[Encountered Problem: Symptoms and Impact]
Originally, the execution plan of an SQL in TiDB 5.1.4 selected the correct index. Suddenly, one day, I found that the execution plan of this SQL in TiDB 5.1.4 chose the wrong index, while the execution plan in TiDB 7.1.0 chose the correct index. Is this a known issue in TiDB 5.1.4 that has been fixed in the new version?

| username: dba远航 | Original post link

The internal optimizations of different versions of tidb-server will definitely vary and undergo adjustments. Apart from differences in parsing, changes in table statistics can also lead to changes in the execution plan.

| username: TiDBer_HzlduICa | Original post link

Would this be considered a malfunction of the TiDB version?

| username: caiyfc | Original post link

I remember that before version 5.3, the default tidb_analyze_version was 2 (it was still an experimental feature at that time), which caused some issues. The solution back then was to delete all the statistics, set tidb_analyze_version to 1, and then collect the statistics for the entire database again. As you can see in the fix below, the default value was also changed to 1. Versions above 5.3 do not have these issues (I don’t remember the exact version).

| username: system | Original post link

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