The estRows is wrong if SQL is executed multiple times #53119
Labels
epic/cardinality-estimation
the optimizer cardinality estimation
may-affects-5.4
This bug maybe affects 5.4.x versions.
may-affects-6.1
may-affects-6.5
may-affects-7.1
may-affects-7.5
may-affects-8.1
severity/moderate
sig/planner
SIG: Planner
type/bug
This issue is a bug.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
CREATE TABLE
tb
(id
int(11) NOT NULL,f1
int(11) DEFAULT NULL,f2
int(11) DEFAULT NULL,f3
int(11) DEFAULT NULL,PRIMARY KEY (
id
),KEY
idx_f1
(f1
) ,KEY
idx_f2
(f2
)) partition by hash(id)
(partition
p0
,partition
p1
,partition
p2
);insert into tb (id,f1,f2,f3) values(1,1,1,1),(2,2,2,2) ......(1000,1000,1000,1000);
insert into tb (id,f1,f2,f3) values(10000,10000,10000,10000),(20000,20000,20000,20000);
analyze table tb;
Execute the following Query first time:
the estRows of Query 'select * from tb where f2>=1000 and f2<=2000' is right.
Then execute the same Querys again:
the estRows of Query 'select * from tb where f2>=1000 and f2<=2000' deviates greatly from the previous one.
Why is there such a large estimation error?
2. What did you expect to see? (Required)
If we execute the same query multiple times, without new DML operation, estRows should be the same
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
pd instance:v8.0.0
tikv instance:v8.0.0
tidb instance:v8.0.0
tiflash instance:v8.0.0
The text was updated successfully, but these errors were encountered: