Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index join inner range is not accurate for clustered index table #38258

Closed
xuyifangreeneyes opened this issue Sep 29, 2022 · 0 comments · Fixed by #38259
Closed

Index join inner range is not accurate for clustered index table #38258

xuyifangreeneyes opened this issue Sep 29, 2022 · 0 comments · Fixed by #38259
Labels
sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.

Comments

@xuyifangreeneyes
Copy link
Contributor

Enhancement

mysql> create table t3(a int, b int, c int);
Query OK, 0 rows affected (0.03 sec)

mysql> create table t4(a int, b int, c int, primary key (a, b) clustered);
Query OK, 0 rows affected (0.03 sec)

mysql> explain select /*+ inl_join(t4) */ * from t3 join t4 on t3.b = t4.b where t4.a = 1;
+------------------------------+----------+-----------+---------------+-----------------------------------------------------------------------------------------------------------------+
| id                           | estRows  | task      | access object | operator info                                                                                                   |
+------------------------------+----------+-----------+---------------+-----------------------------------------------------------------------------------------------------------------+
| IndexJoin_14                 | 12.50    | root      |               | inner join, inner:TableReader_10, outer key:test.t3.b, inner key:test.t4.b, equal cond:eq(test.t3.b, test.t4.b) |
| ├─TableReader_20(Build)      | 9990.00  | root      |               | data:Selection_19                                                                                               |
| │ └─Selection_19             | 9990.00  | cop[tikv] |               | not(isnull(test.t3.b))                                                                                          |
| │   └─TableFullScan_18       | 10000.00 | cop[tikv] | table:t3      | keep order:false, stats:pseudo                                                                                  |
| └─TableReader_10(Probe)      | 0.00     | root      |               | data:Selection_9                                                                                                |
|   └─Selection_9              | 0.00     | cop[tikv] |               | eq(test.t4.a, 1)                                                                                                |
|     └─TableRangeScan_8       | 1.00     | cop[tikv] | table:t4      | range: decided by [test.t3.b], keep order:false, stats:pseudo                                                   |
+------------------------------+----------+-----------+---------------+-----------------------------------------------------------------------------------------------------------------+
7 rows in set (0.02 sec)

range: decided by [test.t3.b] is not accurate. The more accurate range is range: decided by [eq(test.t4.b, test.t3.b) eq(test.t4.a, 1)].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant