mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-04-18 21:44:02 +03:00
MCOL-5539 Put table on small side if it was involved in prev.join. (#2945)
This commit is contained in:
parent
d586975da7
commit
add3a57e8d
@ -705,7 +705,8 @@ void addProjectStepsToBps(TableInfoMap::iterator& mit, BatchPrimitive* bps, JobI
|
|||||||
{
|
{
|
||||||
// if (jobInfo.trace && bps->tableOid() >= 3000)
|
// if (jobInfo.trace && bps->tableOid() >= 3000)
|
||||||
// cout << "1 setting project BPP for " << tbps->toString() << " with "
|
// cout << "1 setting project BPP for " << tbps->toString() << " with "
|
||||||
//<< it->get()->toString() << " and " << (it+1)->get()->toString() << endl;
|
//<< it->get()->toString() << " and " << (it+1)->get()->toString()
|
||||||
|
//<< endl;
|
||||||
bps->setProjectBPP(it->get(), (it + 1)->get());
|
bps->setProjectBPP(it->get(), (it + 1)->get());
|
||||||
|
|
||||||
// this is a two-step project step, remove the token step from id vector
|
// this is a two-step project step, remove the token step from id vector
|
||||||
@ -1876,7 +1877,6 @@ void CircularJoinGraphTransformer::removeAssociatedHashJoinStepFromJoinSteps(con
|
|||||||
if ((tableKey1 == joinEdge.first && tableKey2 == joinEdge.second) ||
|
if ((tableKey1 == joinEdge.first && tableKey2 == joinEdge.second) ||
|
||||||
(tableKey1 == joinEdge.second && tableKey2 == joinEdge.first))
|
(tableKey1 == joinEdge.second && tableKey2 == joinEdge.first))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (jobInfo.trace)
|
if (jobInfo.trace)
|
||||||
std::cout << "Erase matched join step with keys: " << tableKey1 << " <-> " << tableKey2
|
std::cout << "Erase matched join step with keys: " << tableKey1 << " <-> " << tableKey2
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@ -2130,9 +2130,8 @@ void CircularOuterJoinGraphTransformer::analyzeJoinGraph(uint32_t currentTable,
|
|||||||
|
|
||||||
// Sort vertices by weights.
|
// Sort vertices by weights.
|
||||||
std::sort(adjacentListWeighted.begin(), adjacentListWeighted.end(),
|
std::sort(adjacentListWeighted.begin(), adjacentListWeighted.end(),
|
||||||
[](const std::pair<uint32_t, int64_t>& a, const std::pair<uint32_t, int64_t>& b) {
|
[](const std::pair<uint32_t, int64_t>& a, const std::pair<uint32_t, int64_t>& b)
|
||||||
return a.second < b.second;
|
{ return a.second < b.second; });
|
||||||
});
|
|
||||||
|
|
||||||
// For each weighted adjacent node.
|
// For each weighted adjacent node.
|
||||||
for (const auto& adjNodeWeighted : adjacentListWeighted)
|
for (const auto& adjNodeWeighted : adjacentListWeighted)
|
||||||
@ -3796,10 +3795,21 @@ void joinTablesInOrder(uint32_t largest, JobStepVector& joinSteps, TableInfoMap&
|
|||||||
small = tid1;
|
small = tid1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MCOL-5539. If the current large table involved in the previous join and it was not merged into
|
||||||
|
// "single large side multiple small sides" optimization, it should be on a small side,
|
||||||
|
// because it represents a intermediate join result and its rowgroup could be a combination of multiple
|
||||||
|
// rowgroups, therefore it should be sent to BPP as a small side, we cannot read it from disk.
|
||||||
|
if (find(joinedTable.begin(), joinedTable.end(), large) != joinedTable.end() &&
|
||||||
|
joinStepMap[small].second > 0)
|
||||||
|
{
|
||||||
|
std::swap(large, small);
|
||||||
|
}
|
||||||
|
|
||||||
updateJoinSides(small, large, joinInfoMap, smallSides, tableInfoMap, jobInfo);
|
updateJoinSides(small, large, joinInfoMap, smallSides, tableInfoMap, jobInfo);
|
||||||
|
|
||||||
// This is a table for multiple join edges, always a stream table.
|
// This is a table for multiple join edges, always a stream table.
|
||||||
if (joinStepMap[large].second > 2)
|
// If `largest` table is equal to the current `large` table - it's an umstream table.
|
||||||
|
if (joinStepMap[large].second > 2 || large == largest)
|
||||||
umstream = true;
|
umstream = true;
|
||||||
|
|
||||||
if (find(joinedTable.begin(), joinedTable.end(), small) == joinedTable.end())
|
if (find(joinedTable.begin(), joinedTable.end(), small) == joinedTable.end())
|
||||||
|
@ -9,47 +9,47 @@ insert into t1 values (1, 3), (2, 3), (3, 4);
|
|||||||
insert into t2 values (1, 2), (2, 4), (4, 5);
|
insert into t2 values (1, 2), (2, 4), (4, 5);
|
||||||
insert into t3 values (1, 2), (2, 3), (3, 4), (4, 5);
|
insert into t3 values (1, 2), (2, 3), (3, 4), (4, 5);
|
||||||
insert into t4 values (1, 2), (2, 3), (3, 4);
|
insert into t4 values (1, 2), (2, 3), (3, 4);
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t2.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t2.a > 1) order by t1.a;
|
||||||
a b a b a b
|
a b a b a b
|
||||||
1 3 1 2 NULL NULL
|
1 3 1 2 NULL NULL
|
||||||
2 3 2 4 2 3
|
2 3 2 4 2 3
|
||||||
3 4 NULL NULL NULL NULL
|
3 4 NULL NULL NULL NULL
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 1) order by t1.a;
|
||||||
a b a b a b
|
a b a b a b
|
||||||
1 3 1 2 NULL NULL
|
1 3 1 2 NULL NULL
|
||||||
2 3 2 4 3 4
|
2 3 2 4 3 4
|
||||||
3 4 NULL NULL NULL NULL
|
3 4 NULL NULL NULL NULL
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 1 and t2.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 1 and t2.a > 1) order by t1.a;
|
||||||
a b a b a b
|
a b a b a b
|
||||||
1 3 1 2 NULL NULL
|
1 3 1 2 NULL NULL
|
||||||
2 3 2 4 3 4
|
2 3 2 4 3 4
|
||||||
3 4 NULL NULL NULL NULL
|
3 4 NULL NULL NULL NULL
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t2.a > 1 and t1.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t2.a > 1 and t1.a > 1) order by t1.a;
|
||||||
a b a b a b
|
a b a b a b
|
||||||
1 3 1 2 NULL NULL
|
1 3 1 2 NULL NULL
|
||||||
2 3 2 4 3 4
|
2 3 2 4 3 4
|
||||||
3 4 NULL NULL NULL NULL
|
3 4 NULL NULL NULL NULL
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t2.a > 3);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t2.a > 3) order by t1.a;
|
||||||
a b a b a b
|
a b a b a b
|
||||||
1 3 1 2 NULL NULL
|
1 3 1 2 NULL NULL
|
||||||
2 3 2 4 NULL NULL
|
2 3 2 4 NULL NULL
|
||||||
3 4 NULL NULL NULL NULL
|
3 4 NULL NULL NULL NULL
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 3);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 3) order by t1.a;
|
||||||
a b a b a b
|
a b a b a b
|
||||||
1 3 1 2 NULL NULL
|
1 3 1 2 NULL NULL
|
||||||
2 3 2 4 NULL NULL
|
2 3 2 4 NULL NULL
|
||||||
3 4 NULL NULL NULL NULL
|
3 4 NULL NULL NULL NULL
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 1) order by t1.a;
|
||||||
a b a b a b a b
|
a b a b a b a b
|
||||||
1 3 1 2 2 3 NULL NULL
|
1 3 1 2 2 3 NULL NULL
|
||||||
2 3 2 4 2 3 2 3
|
2 3 2 4 2 3 2 3
|
||||||
3 4 NULL NULL 3 4 NULL NULL
|
3 4 NULL NULL 3 4 NULL NULL
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 2);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 2) order by t1.a;
|
||||||
a b a b a b a b
|
a b a b a b a b
|
||||||
1 3 1 2 2 3 NULL NULL
|
1 3 1 2 2 3 NULL NULL
|
||||||
2 3 2 4 2 3 NULL NULL
|
2 3 2 4 2 3 NULL NULL
|
||||||
3 4 NULL NULL 3 4 NULL NULL
|
3 4 NULL NULL 3 4 NULL NULL
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t1.a > 1) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t1.a > 1) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 1) order by t1.a;
|
||||||
a b a b a b a b
|
a b a b a b a b
|
||||||
1 3 1 2 NULL NULL NULL NULL
|
1 3 1 2 NULL NULL NULL NULL
|
||||||
2 3 2 4 2 3 2 3
|
2 3 2 4 2 3 2 3
|
||||||
|
@ -19,15 +19,15 @@ insert into t2 values (1, 2), (2, 4), (4, 5);
|
|||||||
insert into t3 values (1, 2), (2, 3), (3, 4), (4, 5);
|
insert into t3 values (1, 2), (2, 3), (3, 4), (4, 5);
|
||||||
insert into t4 values (1, 2), (2, 3), (3, 4);
|
insert into t4 values (1, 2), (2, 3), (3, 4);
|
||||||
|
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t2.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t2.a > 1) order by t1.a;
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 1) order by t1.a;
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 1 and t2.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 1 and t2.a > 1) order by t1.a;
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t2.a > 1 and t1.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t2.a > 1 and t1.a > 1) order by t1.a;
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t2.a > 3);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t2.a > 3) order by t1.a;
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 3);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.b = t3.b and t1.a > 3) order by t1.a;
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 1) order by t1.a;
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 2);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 2) order by t1.a;
|
||||||
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t1.a > 1) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 1);
|
select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t1.b = t3.b and t1.a > 1) left join t4 on (t3.a = t4.a and t1.a > 1 and t2.a > 1) order by t1.a;
|
||||||
|
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user