planner: EXPLAIN estimate large row count for empty table
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
init
```mysql
drop table t1;
create table t1 (a int primary key);
analyze table t1;
explain SELECT * FROM t1;
```
### 2. What did you expect to see? (Required)
A small number for estRows, since t1 is a empty table. e.g.
```mysql
+-----------------------+---------+-----------+---------------+----------------------+
| id | estRows | task | access object | operator info |
+-----------------------+---------+-----------+---------------+----------------------+
| TableReader_5 | 1.00 | root | | data:TableFullScan_4 |
| └─TableFullScan_4 | 1.00 | cop[tikv] | table:t1 | keep order:false |
+-----------------------+---------+-----------+---------------+----------------------+
```
In fact, sometime TiDB returns this result.
### 3. What did you see instead (Required)
```mysql
+-----------------------+----------+-----------+---------------+--------------------------------+
| id | estRows | task | access object | operator info |
+-----------------------+----------+-----------+---------------+--------------------------------+
| TableReader_5 | 10000.00 | root | | data:TableFullScan_4 |
| └─TableFullScan_4 | 10000.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
+-----------------------+----------+-----------+---------------+--------------------------------+
```
### 4. Some other info
It seems that this bug is unstable due to unknown reasons. Some behaviours may help to trigger this bug.
```mysql
session1 > begin;
session2 > begin;
session2 > explain SELECT * FROM t1;
session2 > explain SELECT * FROM t1 for update;
session1 > commit;
session2 > commit;
```
### 5. What is your TiDB version? (Required)
```mysql
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.5.0
Edition: Community
Git Commit Hash: 706c3fa3c526cdba5b3e9f066b1a568fb96c56e3
Git Branch: heads/refs/tags/v6.5.0
UTC Build Time: 2022-12-27 03:50:44
GoVersion: go1.19.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
```
Contributor guide
Assessment
This issue has not been assessed yet.