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

inl_join hints has wrong warrings in the cte query block #53767

Closed
Damon-Guo opened this issue Jun 3, 2024 · 2 comments · Fixed by #53921
Closed

inl_join hints has wrong warrings in the cte query block #53767

Damon-Guo opened this issue Jun 3, 2024 · 2 comments · Fixed by #53921

Comments

@Damon-Guo
Copy link

Damon-Guo commented Jun 3, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE t_employees  (
    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    fname VARCHAR(25) NOT NULL,
    lname VARCHAR(25) NOT NULL,
    store_id INT NOT NULL,
    department_id INT NOT NULL
);
alter table t_employees add index idx(department_id);

explain 
with t as (select  /*+ inl_join(e) */em.* from t_employees em join t_employees e where em.store_id=e.department_id )
select * from t ;

The hint is worked, but it has some wrong warnings.

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

id                     |estRows |task     |access object                    |operator info                                                                                                                                                                            |
-----------------------+--------+---------+---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
IndexJoin_16           |12500.00|root     |                                 |inner join, inner:IndexReader_15, outer key:test.t_employees.store_id, inner key:test.t_employees.department_id, equal cond:eq(test.t_employees.store_id, test.t_employees.department_id)|
├─TableReader_24(Build)|10000.00|root     |                                 |data:TableFullScan_23                                                                                                                                                                    |
│ └─TableFullScan_23   |10000.00|cop[tikv]|table:em                         |keep order:false, stats:pseudo                                                                                                                                                           |
└─IndexReader_15(Probe)|12500.00|root     |                                 |index:IndexRangeScan_14                                                                                                                                                                  |
  └─IndexRangeScan_14  |12500.00|cop[tikv]|table:e, index:idx(department_id)|range: decided by [eq(test.t_employees.department_id, test.t_employees.store_id)], keep order:false, stats:pseudo                                                                        |

the explain use index join without warnings.

3. What did you see instead (Required)

id                     |estRows |task     |access object                    |operator info                                                                                                                                                                            |
-----------------------+--------+---------+---------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
IndexJoin_16           |12500.00|root     |                                 |inner join, inner:IndexReader_15, outer key:test.t_employees.store_id, inner key:test.t_employees.department_id, equal cond:eq(test.t_employees.store_id, test.t_employees.department_id)|
├─TableReader_24(Build)|10000.00|root     |                                 |data:TableFullScan_23                                                                                                                                                                    |
│ └─TableFullScan_23   |10000.00|cop[tikv]|table:em                         |keep order:false, stats:pseudo                                                                                                                                                           |
└─IndexReader_15(Probe)|12500.00|root     |                                 |index:IndexRangeScan_14                                                                                                                                                                  |
  └─IndexRangeScan_14  |12500.00|cop[tikv]|table:e, index:idx(department_id)|range: decided by [eq(test.t_employees.department_id, test.t_employees.store_id)], keep order:false, stats:pseudo                                                                        |

the explain use index join with warnings
There are no matching table names for (e) in optimizer hint /*+ INL_JOIN(e, e) / or /+ TIDB_INLJ(e, e) */. Maybe you can use the table alias name

4. What is your TiDB version? (Required)

Release Version: v8.1.0
Edition: Community
Git Commit Hash: 945d07c
Git Branch: HEAD
UTC Build Time: 2024-05-21 03:51:57
GoVersion: go1.21.10
Race Enabled: false
Check Table Before Drop: false
Store: tikv

@Damon-Guo Damon-Guo added the type/bug The issue is confirmed as a bug. label Jun 3, 2024
@Damon-Guo Damon-Guo changed the title inl_join hint has wrong warrings in the cte query block inl_join hints has wrong warrings in the cte query block Jun 3, 2024
@hawkingrei
Copy link
Member

the same as #53454

@jebter jebter added sig/planner SIG: Planner duplicate Issues or pull requests already exists. labels Jun 4, 2024
@Damon-Guo
Copy link
Author

I think it is not same as #53454 , the hint of inl_join is not worked in issue #53454 ,but it works in this issue

@hawkingrei hawkingrei added severity/moderate and removed duplicate Issues or pull requests already exists. labels Jun 6, 2024
@hawkingrei hawkingrei self-assigned this Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants