-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
severity/moderatesig/plannerSIG: PlannerSIG: Plannertype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Description
Report
Repeatedly updating the same row will cause the stats_healthy to become low, which affects the correctness of the execution plan
1. Minimal reproduce step (Required)
mysql> create table t(a int);
mysql> insert into t values(1),(1),(1),(1),(1),(1),(1),(1);
Query OK, 8 row affected (0.01 sec)
mysql> show stats_meta where table_name='t';
+---------+------------+----------------+---------------------+--------------+-----------+
| Db_name | Table_name | Partition_name | Update_time | Modify_count | Row_count |
+---------+------------+----------------+---------------------+--------------+-----------+
| test | t | | 2023-10-10 16:36:50 | 0 | 8 |
+---------+------------+----------------+---------------------+--------------+-----------+
1 row in set (0.00 sec)
mysql> update t set a=2 where a=1 limit 1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings:
mysql> update t set a=3 where a=2 limit 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from t;
+------+
| a |
+------+
| 3 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
+------+
8 rows in set (0.00 sec)
mysql> update t set a=4 where a=3 limit 1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
2. What did you expect to see? (Required)
mysql> show stats_meta where table_name='t';
+---------+------------+----------------+---------------------+--------------+-----------+
| Db_name | Table_name | Partition_name | Update_time | Modify_count | Row_count |
+---------+------------+----------------+---------------------+--------------+-----------+
| test | t | | 2023-10-10 16:40:47 | 1 | 8 |
+---------+------------+----------------+---------------------+--------------+-----------+
1 row in set (0.00 sec)
mysql> show stats_healthy where table_name='t';
+---------+------------+----------------+---------+
| Db_name | Table_name | Partition_name | Healthy |
+---------+------------+----------------+---------+
| test | t | | 88 |
+---------+------------+----------------+---------+
1 row in set (0.00 sec)
3. What did you see instead (Required)
mysql> show stats_meta where table_name='t';
+---------+------------+----------------+---------------------+--------------+-----------+
| Db_name | Table_name | Partition_name | Update_time | Modify_count | Row_count |
+---------+------------+----------------+---------------------+--------------+-----------+
| test | t | | 2023-10-10 16:40:47 | 3 | 8 |
+---------+------------+----------------+---------------------+--------------+-----------+
1 row in set (0.00 sec)
mysql> show stats_healthy where table_name='t';
+---------+------------+----------------+---------+
| Db_name | Table_name | Partition_name | Healthy |
+---------+------------+----------------+---------+
| test | t | | 12 |
+---------+------------+----------------+---------+
1 row in set (0.00 sec)
4. What is your TiDB version? (Required)
v6.5.3
Metadata
Metadata
Assignees
Labels
severity/moderatesig/plannerSIG: PlannerSIG: Plannertype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.