statistics: inaccurate modify-count/row-count after analyzing a table #22934
Labels
affects-6.1
component/statistics
severity/minor
sig/planner
SIG: Planner
type/bug
The issue is confirmed as a bug.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
These two
show stats_meta
statements should have the same result.3. What did you see instead (Required)
They have different results.
4. What is your TiDB version? (Required)
5. The Root cause of this problem.
Background: at the end of an insert statement, TiDB records the number of new-inserted rows as
StatsDelta
which will be updated intoModifiedCount
andRowCount
later by a background goroutine.The Root Cause: when the analyze-table statement is processed, the
StatsDelta
generated by the previous insert statement has not been handled. When the analyze-table statement finished, we gotModifyCount, RowCount = 0, 5
. And later when TiDB dealt withStatsDelta
, the five rows were count again, and then we gotModifyCount, RowCount = 5, 10
.#15779 has the same root cause.
6. How to solve this problem.
We should abandon all
StatsDelta
whose generated-time is before the time of the last analyze-statement.Here is another test:
The text was updated successfully, but these errors were encountered: