-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.component/statisticsseverity/majorsig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Here is a small example to demonstrate the issue.
I add time.Sleep(20 * time.Minute)
into (*Handle).InitStats
to simulate slow init stats.
mysql> create table t1(a int, b int, index idx(a));
Query OK, 0 rows affected (0.02 sec)
-- insert data into t1
mysql> analyze table t1;
Query OK, 0 rows affected, 1 warning (0.05 sec)
Then restart the tidb-server.
mysql> explain select * from t1 where a > 1;
+-------------------------+----------+-----------+---------------+--------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------+----------+-----------+---------------+--------------------------------+
| TableReader_7 | 3333.33 | root | | data:Selection_6 |
| └─Selection_6 | 3333.33 | cop[tikv] | | gt(test.t1.a, 1) |
| └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+--------------------------------+
3 rows in set (0.00 sec)
mysql> show stats_meta;
Empty set (0.00 sec)
mysql> show stats_histograms;
Empty set (0.00 sec)
2. What did you expect to see? (Required)
We hope the optimizer avoids using pseudo stats to make decisions. For example, tidb can choose to wait for init stats to finish before providing service.
3. What did you see instead (Required)
The optimizer uses pseudo stats during init stats, which may lead to bad plans.
4. What is your TiDB version? (Required)
master
Metadata
Metadata
Assignees
Labels
affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.component/statisticsseverity/majorsig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.