Skip to content

The estrows is wrong for inner operator of index join #59902

@pcqz

Description

@pcqz

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t1(a int primary key, b int);
create table t2(a int, b int, key idx(a));
set tidb_enable_inl_join_inner_multi_pattern=on;
explain select t1.b,(select count(*) from t2 where t2.a=t1.a) as a from t1 where t1.a=1;

2. What did you expect to see? (Required)

The hashagg operator has the same estrows with the selection operator.

3. What did you see instead (Required)

+-----------------------------------+---------+-----------+----------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
| id                                | estRows | task      | access object              | operator info                                                                                                                            |
+-----------------------------------+---------+-----------+----------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_12                     | 1.00    | root      |                            | test.t1.b, ifnull(Column#10, 0)->Column#10                                                                                               |
| └─IndexHashJoin_21                | 1.00    | root      |                            | left outer join, inner:HashAgg_17, left side:Point_Get_39, outer key:test.t1.a, inner key:test.t2.a, equal cond:eq(test.t1.a, test.t2.a) |
|   ├─Point_Get_39(Build)           | 1.00    | root      | table:t1, index:PRIMARY(a) |                                                                                                                                          |
|   └─HashAgg_17(Probe)             | 7992.00 | root      |                            | group by:test.t2.a, funcs:count(Column#11)->Column#10, funcs:firstrow(test.t2.a)->test.t2.a                                              |
|     └─IndexReader_18              | 7992.00 | root      |                            | index:HashAgg_16                                                                                                                         |
|       └─HashAgg_16                | 7992.00 | cop[tikv] |                            | group by:test.t2.a, funcs:count(1)->Column#11                                                                                            |
|         └─Selection_15            | 1.00    | cop[tikv] |                            | not(isnull(test.t2.a))                                                                                                                   |
|           └─IndexRangeScan_14     | 1.00    | cop[tikv] | table:t2, index:idx(a)     | range: decided by [eq(test.t2.a, test.t1.a)], keep order:false, stats:pseudo                                                             |
+-----------------------------------+---------+-----------+----------------------------+------------------------------------------------------------------------------------------------------------------------------------------+

4. What is your TiDB version? (Required)

v8.5.1

Metadata

Metadata

Labels

affects-8.5This bug affects the 8.5.x(LTS) versions.report/customerCustomers have encountered this bug.severity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions