-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
planner: add aggregation hints TIDB_HASHAGG
and TIDB_STREAMAGG
#11364
Conversation
Codecov Report
@@ Coverage Diff @@
## master #11364 +/- ##
===========================================
Coverage 81.6243% 81.6243%
===========================================
Files 426 426
Lines 93640 93640
===========================================
Hits 76433 76433
Misses 11807 11807
Partials 5400 5400 |
ecd3e00
to
ff1f239
Compare
/run-all-tests |
PTAL. @zz-jason @lamxTyler |
TIDB_HASHAGG
and TIDB_STREAMAGG
TIDB_HASHAGG
and TIDB_STREAMAGG
37eff4e
to
5accbd8
Compare
/run-all-tests |
fa37100
to
2c46284
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We should update the version of parser in go.mod before merging this commit. |
80af97d
to
74c1bf3
Compare
all, desc := prop.AllSameOrder() | ||
if len(la.possibleProperties) == 0 || !all { | ||
if !all { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not resolved?
@@ -1570,3 +1570,71 @@ func (s *testPlanSuite) TestIndexJoinHint(c *C) { | |||
} | |||
} | |||
} | |||
|
|||
func (s *testPlanSuite) TestAggregationHints(c *C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test case which contains subquery?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the first one, because possibleChildProperties
are only possible... We'd better not rely too much on it, I handle this in line 1272 - 1275, you can take a look.
For the test case, I will add them soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding test case, find another bug. Fix it soon...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
I'm still curious that, is this expectable? CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
KEY `a` (`a`)
);
tidb> desc select /*+ TIDB_HJ(t) */ a, count(b) from t group by a order by a;
+--------------------------+----------+------+--------------------------------------------------------------------+
| id | count | task | operator info |
+--------------------------+----------+------+--------------------------------------------------------------------+
| Projection_22 | 8000.00 | root | test.t.a, 2_col_0 |
| └─StreamAgg_24 | 8000.00 | root | group by:test.t.a, funcs:count(test.t.b), firstrow(test.t.a) |
| └─Projection_21 | 10000.00 | root | test.t.a, test.t.b |
| └─IndexLookUp_20 | 10000.00 | root | |
| ├─IndexScan_18 | 10000.00 | cop | table:t, index:a, range:[NULL,+inf], keep order:true, stats:pseudo |
| └─TableScan_19 | 10000.00 | cop | table:t, keep order:false, stats:pseudo |
+--------------------------+----------+------+--------------------------------------------------------------------+
6 rows in set, 1 warning (0.00 sec)
tidb> show warnings;
+---------+------+-----------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------------------------------------------------------------------------------+
| Warning | 1815 | There are no matching table names for (t) in optimizer hint /*+ TIDB_HJ(t) */. Maybe you can use the table alias name |
+---------+------+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec) |
I know this case, it's expected, but looks weird, I will fix it in another PR. @XuHuaiyu |
What problem does this PR solve?
Add Optimizer Hints
TIDB_HASHAGG
andTIDB_STREAMAGG
.What is changed and how it works?
Handle the hint from parser, and enforce planner to choose the aggregation type.
Related parser PR: pingcap/parser#394
Check List
Tests
Code changes
Side effects
Related changes