Skip to content

Commit d08419b

Browse files
authored
[CBO] added enableshuffleelimination flag (#15218)
1 parent bf4f55b commit d08419b

16 files changed

+192
-189
lines changed

ydb/core/kqp/opt/logical/kqp_opt_log.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class TKqpLogicalOptTransformer : public TOptimizeTransformerBase {
9292
public:
9393
TStatus DoTransform(TExprNode::TPtr input, TExprNode::TPtr& output, TExprContext& ctx) override {
9494
auto status = TOptimizeTransformerBase::DoTransform(input, output, ctx);
95-
95+
9696
if (status == TStatus::Ok) {
9797
for (const auto& hint: KqpCtx.GetOptimizerHints().GetUnappliedString()) {
9898
ctx.AddWarning(YqlIssue({}, TIssuesIds::YQL_UNUSED_HINT, "Unapplied hint: " + hint));
@@ -118,7 +118,7 @@ class TKqpLogicalOptTransformer : public TOptimizeTransformerBase {
118118
TMaybeNode<TExprBase> RewriteAggregate(TExprBase node, TExprContext& ctx) {
119119
TMaybeNode<TExprBase> output;
120120
auto aggregate = node.Cast<TCoAggregateBase>();
121-
auto hopSetting = GetSetting(aggregate.Settings().Ref(), "hopping");
121+
auto hopSetting = GetSetting(aggregate.Settings().Ref(), "hopping");
122122
if (hopSetting) {
123123
auto input = aggregate.Input().Maybe<TDqConnection>();
124124
if (!input) {
@@ -163,8 +163,9 @@ class TKqpLogicalOptTransformer : public TOptimizeTransformerBase {
163163
TMaybeNode<TExprBase> OptimizeEquiJoinWithCosts(TExprBase node, TExprContext& ctx) {
164164
auto maxDPhypDPTableSize = Config->MaxDPHypDPTableSize.Get().GetOrElse(TDqSettings::TDefault::MaxDPHypDPTableSize);
165165
auto optLevel = Config->CostBasedOptimizationLevel.Get().GetOrElse(Config->DefaultCostBasedOptimizationLevel);
166+
bool enableShuffleElimination = KqpCtx.Config->OptShuffleElimination.Get().GetOrElse(false);;
166167
auto providerCtx = TKqpProviderContext(KqpCtx, optLevel);
167-
auto opt = std::unique_ptr<IOptimizerNew>(MakeNativeOptimizerNew(providerCtx, maxDPhypDPTableSize, ctx));
168+
auto opt = std::unique_ptr<IOptimizerNew>(MakeNativeOptimizerNew(providerCtx, maxDPhypDPTableSize, ctx, enableShuffleElimination));
168169
TExprBase output = DqOptimizeEquiJoinWithCosts(node, ctx, TypesCtx, optLevel,
169170
*opt, [](auto& rels, auto label, auto node, auto stat) {
170171
rels.emplace_back(std::make_shared<TKqpRelOptimizerNode>(TString(label), *stat, node));

ydb/core/kqp/ut/join/data/join_order/lookupbug.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
"op_name":"LeftJoin (MapJoin)",
77
"args":
88
[
9-
{
10-
"op_name":"TableFullScan",
11-
"table":"quotas_browsers_relation"
12-
},
139
{
1410
"op_name":"LeftJoin (MapJoin)",
1511
"args":
1612
[
1713
{
1814
"op_name":"TableFullScan",
19-
"table":"browsers"
15+
"table":"quotas_browsers_relation"
2016
},
2117
{
22-
"op_name":"TableFullScan",
23-
"table":"browser_groups"
18+
"op_name":"TableLookup",
19+
"table":"browsers"
2420
}
2521
]
22+
},
23+
{
24+
"op_name":"TableLookup",
25+
"table":"browser_groups"
2626
}
2727
]
2828
},

ydb/core/kqp/ut/join/data/join_order/tpcc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"args":
44
[
55
{
6-
"op_name":"TableRangeScan",
7-
"table":"test\/tpcc\/order_line"
6+
"op_name":"TableLookup",
7+
"table":"test\/tpcc\/stock"
88
},
99
{
1010
"op_name":"TableRangeScan",
11-
"table":"test\/tpcc\/stock"
11+
"table":"test\/tpcc\/order_line"
1212
}
1313
]
1414
}

ydb/core/kqp/ut/join/data/join_order/tpcds64_small_1000s.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"op_name":"InnerJoin (MapJoin)",
2+
"op_name":"InnerJoin (Grace)",
33
"args":
44
[
55
{

ydb/core/kqp/ut/join/data/join_order/tpcds64_small_1000s_column_store.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"op_name":"InnerJoin (MapJoin)",
2+
"op_name":"InnerJoin (Grace)",
33
"args":
44
[
55
{

ydb/core/kqp/ut/join/data/join_order/tpcds78_1000s.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,37 @@
77
"args":
88
[
99
{
10-
"op_name":"InnerJoin (MapJoin)",
10+
"op_name":"LeftJoin (Grace)",
1111
"args":
1212
[
1313
{
14-
"op_name":"LeftJoin (Grace)",
14+
"op_name":"InnerJoin (MapJoin)",
1515
"args":
1616
[
1717
{
1818
"op_name":"TableFullScan",
1919
"table":"test\/ds\/store_sales"
2020
},
2121
{
22-
"op_name":"TableFullScan",
23-
"table":"test\/ds\/store_returns"
22+
"op_name":"Union",
23+
"args":
24+
[
25+
{
26+
"op_name":"TableFullScan",
27+
"table":"test\/ds\/date_dim"
28+
}
29+
]
2430
}
2531
]
2632
},
2733
{
28-
"op_name":"Union",
29-
"args":
30-
[
31-
{
32-
"op_name":"TableFullScan",
33-
"table":"test\/ds\/date_dim"
34-
}
35-
]
34+
"op_name":"TableFullScan",
35+
"table":"test\/ds\/store_returns"
3636
}
3737
]
3838
},
3939
{
40-
"op_name":"InnerJoin (Grace)",
40+
"op_name":"InnerJoin (MapJoin)",
4141
"args":
4242
[
4343
{
@@ -46,11 +46,11 @@
4646
[
4747
{
4848
"op_name":"TableFullScan",
49-
"table":"test\/ds\/catalog_sales"
49+
"table":"test\/ds\/web_sales"
5050
},
5151
{
5252
"op_name":"TableFullScan",
53-
"table":"test\/ds\/catalog_returns"
53+
"table":"test\/ds\/web_returns"
5454
}
5555
]
5656
},
@@ -69,7 +69,7 @@
6969
]
7070
},
7171
{
72-
"op_name":"InnerJoin (Grace)",
72+
"op_name":"InnerJoin (MapJoin)",
7373
"args":
7474
[
7575
{
@@ -78,11 +78,11 @@
7878
[
7979
{
8080
"op_name":"TableFullScan",
81-
"table":"test\/ds\/web_sales"
81+
"table":"test\/ds\/catalog_sales"
8282
},
8383
{
8484
"op_name":"TableFullScan",
85-
"table":"test\/ds\/web_returns"
85+
"table":"test\/ds\/catalog_returns"
8686
}
8787
]
8888
},

ydb/core/kqp/ut/join/data/join_order/tpcds78_1000s_column_store.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"args":
88
[
99
{
10-
"op_name":"InnerJoin (MapJoin)",
10+
"op_name":"LeftJoin (Grace)",
1111
"args":
1212
[
1313
{
14-
"op_name":"LeftJoin (Grace)",
14+
"op_name":"InnerJoin (MapJoin)",
1515
"args":
1616
[
1717
{
@@ -20,18 +20,18 @@
2020
},
2121
{
2222
"op_name":"TableFullScan",
23-
"table":"test\/ds\/store_returns"
23+
"table":"test\/ds\/date_dim"
2424
}
2525
]
2626
},
2727
{
2828
"op_name":"TableFullScan",
29-
"table":"test\/ds\/date_dim"
29+
"table":"test\/ds\/store_returns"
3030
}
3131
]
3232
},
3333
{
34-
"op_name":"InnerJoin (Grace)",
34+
"op_name":"InnerJoin (MapJoin)",
3535
"args":
3636
[
3737
{
@@ -40,11 +40,11 @@
4040
[
4141
{
4242
"op_name":"TableFullScan",
43-
"table":"test\/ds\/catalog_sales"
43+
"table":"test\/ds\/web_sales"
4444
},
4545
{
4646
"op_name":"TableFullScan",
47-
"table":"test\/ds\/catalog_returns"
47+
"table":"test\/ds\/web_returns"
4848
}
4949
]
5050
},
@@ -57,7 +57,7 @@
5757
]
5858
},
5959
{
60-
"op_name":"InnerJoin (Grace)",
60+
"op_name":"InnerJoin (MapJoin)",
6161
"args":
6262
[
6363
{
@@ -66,11 +66,11 @@
6666
[
6767
{
6868
"op_name":"TableFullScan",
69-
"table":"test\/ds\/web_sales"
69+
"table":"test\/ds\/catalog_sales"
7070
},
7171
{
7272
"op_name":"TableFullScan",
73-
"table":"test\/ds\/web_returns"
73+
"table":"test\/ds\/catalog_returns"
7474
}
7575
]
7676
},

ydb/core/kqp/ut/join/data/join_order/tpch2_1000s.json

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,75 +8,75 @@
88
[
99
{
1010
"op_name":"TableFullScan",
11-
"table":"part"
11+
"table":"partsupp"
1212
},
1313
{
1414
"op_name":"InnerJoin (MapJoin)",
1515
"args":
1616
[
17+
{
18+
"op_name":"TableFullScan",
19+
"table":"supplier"
20+
},
1721
{
1822
"op_name":"InnerJoin (MapJoin)",
1923
"args":
2024
[
2125
{
22-
"op_name":"InnerJoin (Grace)",
23-
"args":
24-
[
25-
{
26-
"op_name":"TableFullScan",
27-
"table":"partsupp"
28-
},
29-
{
30-
"op_name":"TableFullScan",
31-
"table":"supplier"
32-
}
33-
]
26+
"op_name":"TableLookup",
27+
"table":"region"
3428
},
3529
{
3630
"op_name":"TableFullScan",
3731
"table":"nation"
3832
}
3933
]
40-
},
41-
{
42-
"op_name":"TableFullScan",
43-
"table":"region"
4434
}
4535
]
4636
}
4737
]
4838
},
4939
{
50-
"op_name":"InnerJoin (MapJoin)",
40+
"op_name":"InnerJoin (Grace)",
5141
"args":
5242
[
5343
{
54-
"op_name":"InnerJoin (MapJoin)",
44+
"op_name":"InnerJoin (Grace)",
5545
"args":
5646
[
5747
{
58-
"op_name":"InnerJoin (Grace)",
48+
"op_name":"TableFullScan",
49+
"table":"partsupp"
50+
},
51+
{
52+
"op_name":"InnerJoin (MapJoin)",
5953
"args":
6054
[
6155
{
6256
"op_name":"TableFullScan",
63-
"table":"partsupp"
57+
"table":"supplier"
6458
},
6559
{
66-
"op_name":"TableFullScan",
67-
"table":"supplier"
60+
"op_name":"InnerJoin (MapJoin)",
61+
"args":
62+
[
63+
{
64+
"op_name":"TableLookup",
65+
"table":"region"
66+
},
67+
{
68+
"op_name":"TableFullScan",
69+
"table":"nation"
70+
}
71+
]
6872
}
6973
]
70-
},
71-
{
72-
"op_name":"TableFullScan",
73-
"table":"nation"
7474
}
7575
]
7676
},
7777
{
7878
"op_name":"TableFullScan",
79-
"table":"region"
79+
"table":"part"
8080
}
8181
]
8282
}

0 commit comments

Comments
 (0)