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

hints does not work for subquery including agg operator #35004

Closed
pcqz opened this issue May 27, 2022 · 1 comment · May be fixed by #38163
Closed

hints does not work for subquery including agg operator #35004

pcqz opened this issue May 27, 2022 · 1 comment · May be fixed by #38163
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@pcqz
Copy link

pcqz commented May 27, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t1(id int, key(id));
Query OK, 0 rows affected (0.09 sec)

mysql> create table t2(id int, key(id));
Query OK, 0 rows affected (0.09 sec)

mysql> explain select  /*+ merge_join(b) */ * from (select * from t1) a join (select id, count(1) from t2 group by t2.id) b on a.id=b.id;
+--------------------------------+---------+-----------+------------------------+---------------------------------------------------------------------------------------+
| id                             | estRows | task      | access object          | operator info                                                                         |
+--------------------------------+---------+-----------+------------------------+---------------------------------------------------------------------------------------+
| Projection_10                  | 9990.00 | root      |                        | test.t1.id, test.t2.id, Column#5                                                      |
| └─HashJoin_23                  | 9990.00 | root      |                        | inner join, equal:[eq(test.t1.id, test.t2.id)]                                        |
|   ├─HashAgg_36(Build)          | 7992.00 | root      |                        | group by:test.t2.id, funcs:count(1)->Column#5, funcs:firstrow(test.t2.id)->test.t2.id |
|   │ └─IndexReader_43           | 9990.00 | root      |                        | index:IndexFullScan_42                                                                |
|   │   └─IndexFullScan_42       | 9990.00 | cop[tikv] | table:t2, index:id(id) | keep order:false, stats:pseudo                                                        |
|   └─IndexReader_47(Probe)      | 9990.00 | root      |                        | index:IndexFullScan_46                                                                |
|     └─IndexFullScan_46         | 9990.00 | cop[tikv] | table:t1, index:id(id) | keep order:false, stats:pseudo                                                        |
+--------------------------------+---------+-----------+------------------------+---------------------------------------------------------------------------------------+
7 rows in set, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+------------------------------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                                        |
+---------+------+------------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1815 | There are no matching table names for (b) in optimizer hint /*+ MERGE_JOIN(b) */ or /*+ TIDB_SMJ(b) */. Maybe you can use the table alias name |
+---------+------+------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

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

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

master

@pcqz pcqz added the type/bug The issue is confirmed as a bug. label May 27, 2022
@Yisaer Yisaer added the sig/planner SIG: Planner label May 27, 2022
@jebter jebter added severity/major affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 labels May 27, 2022
@ti-chi-bot ti-chi-bot added the may-affects-4.0 This bug maybe affects 4.0.x versions. label May 27, 2022
@ChenPeng2013 ChenPeng2013 added the affects-4.0 This bug affects 4.0.x versions. label Jun 10, 2022
@ti-chi-bot ti-chi-bot removed the may-affects-4.0 This bug maybe affects 4.0.x versions. label Jun 10, 2022
@qw4990
Copy link
Contributor

qw4990 commented Oct 30, 2023

Solved by #46271

@qw4990 qw4990 closed this as completed Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants