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_STREAMAGGTIDB_HASHAGG and TIDB_STREAMAGG
37eff4e to
5accbd8
Compare
|
/run-all-tests |
fa37100 to
2c46284
Compare
|
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 { |
| } | ||
| } | ||
|
|
||
| func (s *testPlanSuite) TestAggregationHints(c *C) { |
There was a problem hiding this comment.
Add a test case which contains subquery?
There was a problem hiding this comment.
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.
When adding test case, find another bug. Fix it soon...
|
/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_HASHAGGandTIDB_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