Closed zz-jason closed 4 years ago
How about let me fix it? @zz-jason @eurekaka
How about let me fix it? @zz-jason @eurekaka
Sure! Thanks for your contribution!
@haplone You can refer to buildRangeDecidedByInformation
in https://github.com/pingcap/tidb/pull/8471. This part of that pr solved this problem.
Also note that, You need to use TIDB_INLJ(t_inner)
instead of TIDB_INLJ(t_outer)
in master.
请教个问题,我对这个 TIDB_INLJ
有些疑问。根据文档介绍,TIDB_INLJ
的作用是提示优化器内表的候选表,但是通过上面的例子还有 #8039 中的例子,貌似它的代码逻辑写反了。
请教个问题,我对这个
TIDB_INLJ
有些疑问。根据文档介绍,TIDB_INLJ
的作用是提示优化器内表的候选表,但是通过上面的例子还有 #8039 中的例子,貌似它的代码逻辑写反了。
@jarvys What's the version of TiDB that you are using? In old versions, the hint specifies the outer table, not the inner table.
@zz-jason I got it. In new version TIDB_INLJ hint behavior has been modified. I am using the 2.x version now, but reading the latest documentation, so I am confused.
It has been fixed in the latest master branch:
TiDB(root@127.0.0.1:test) > desc select /*+ TIDB_INLJ(t_inner) */ * from t_outer left join t_inner on t_outer.b = t_inner.b and t_inner.a = 1;
+-----------------------------+----------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | operator info |
+-----------------------------+----------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------+
| IndexJoin_9 | 10000.00 | root | left outer join, inner:IndexReader_8, outer key:test.t_outer.b, inner key:test.t_inner.b |
| ├─TableReader_18(Build) | 10000.00 | root | data:TableFullScan_17 |
| │ └─TableFullScan_17 | 10000.00 | cop[tikv] | table:t_outer, keep order:false, stats:pseudo |
| └─IndexReader_8(Probe) | 0.01 | root | index:Selection_7 |
| └─Selection_7 | 0.01 | cop[tikv] | not(isnull(test.t_inner.b)) |
| └─IndexRangeScan_6 | 0.01 | cop[tikv] | table:t_inner, index:a, b, range: decided by [eq(test.t_inner.b, test.t_outer.b) eq(test.t_inner.a, 1)], keep order:false, stats:pseudo |
+-----------------------------+----------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------+
6 rows in set (0.00 sec)
Bug Report
For now, the range info for
IndexScan_6
is:It's not completely correct. It's better to be displayed like:
tidb version:
discovered in this issue: https://github.com/pingcap/tidb/issues/8039