Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/planner/core/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ func fillIndexPath(ds *logicalop.DataSource, path *util.AccessPath, conds []expr
}
// Don't add one column twice to the index. May cause unexpected errors.
if !alreadyHandle {
path.FullIdxCols = append(path.FullIdxCols, handleCol)
path.FullIdxColLens = append(path.FullIdxColLens, types.UnspecifiedLength)
path.IdxCols = append(path.IdxCols, handleCol)
path.IdxColLens = append(path.IdxColLens, types.UnspecifiedLength)
// Also updates the map that maps the index id to its prefix column ids.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,3 +773,21 @@ _tidb_rowid
1
2
3
drop table if exists t, t1;
create table t(a int);
create table t1(a int primary key, b int, index idx(b));
insert into t values(1), (2), (123);
insert into t1 values(2, 123), (123, 2);
set tidb_opt_fix_control='44855:on';
explain select /*+ inl_join(t1), use_index(t1, idx) */ * from t join t1 on t.a = t1.a and t1.b = 123;
id estRows task access object operator info
Projection_9 12.50 root test.t.a, test.t1.a, test.t1.b
└─IndexJoin_12 12.50 root inner join, inner:IndexReader_11, outer key:test.t.a, inner key:test.t1.a, equal cond:eq(test.t.a, test.t1.a)
├─TableReader_20(Build) 9990.00 root data:Selection_19
│ └─Selection_19 9990.00 cop[tikv] not(isnull(test.t.a))
│ └─TableFullScan_18 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
└─IndexReader_11(Probe) 12.50 root index:IndexRangeScan_10
└─IndexRangeScan_10 12.50 cop[tikv] table:t1, index:idx(b) range: decided by [eq(test.t1.a, test.t.a) eq(test.t1.b, 123)], keep order:false, stats:pseudo
select /*+ inl_join(t1), use_index(t1, idx) */ * from t join t1 on t.a = t1.a and t1.b = 123;
a a b
2 2 123
10 changes: 10 additions & 0 deletions tests/integrationtest/t/planner/core/issuetest/planner_issue.test
Original file line number Diff line number Diff line change
Expand Up @@ -542,3 +542,13 @@ insert into t values (1, 10);
insert into t values (2, 20);
insert into t values (3, 30);
select _tidb_rowid from t where id in (1, 2, 3);

# TestIssue59762
drop table if exists t, t1;
create table t(a int);
create table t1(a int primary key, b int, index idx(b));
insert into t values(1), (2), (123);
insert into t1 values(2, 123), (123, 2);
set tidb_opt_fix_control='44855:on';
explain select /*+ inl_join(t1), use_index(t1, idx) */ * from t join t1 on t.a = t1.a and t1.b = 123;
select /*+ inl_join(t1), use_index(t1, idx) */ * from t join t1 on t.a = t1.a and t1.b = 123;