You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-10-31 18:30:33 +03:00
feat(rbo,rules,QA): replace monotonic counter with column_name->col_index map and added fields to activate existing filters pushdown machinery.
This commit is contained in:
@@ -945,6 +945,7 @@ class CalpontSelectExecutionPlan : public CalpontExecutionPlan
|
||||
bool fHasOrderBy = false;
|
||||
|
||||
// for Select clause subquery
|
||||
// Populated from derived found in projection list.
|
||||
SelectList fSelectSubList;
|
||||
|
||||
// @bug3321, for string scan blocks
|
||||
@@ -961,6 +962,7 @@ class CalpontSelectExecutionPlan : public CalpontExecutionPlan
|
||||
uint32_t fOrderByThreads = 1;
|
||||
|
||||
// Derived table involved in the query. For derived table optimization
|
||||
// Populated from derived found in filters.
|
||||
std::vector<SCSEP> fSubSelectList;
|
||||
|
||||
boost::uuids::uuid fUuid{};
|
||||
|
||||
@@ -7610,6 +7610,14 @@ int cs_get_select_plan(ha_columnstore_select_handler* handler, THD* thd, SCSEP&
|
||||
}
|
||||
}
|
||||
|
||||
derivedTableOptimization(&gwi, csep);
|
||||
if (csep->traceOn())
|
||||
{
|
||||
cerr << "---------------- cs_get_select_plan 2nd derived table optimization pass EXECUTION PLAN ----------------" << endl;
|
||||
cerr << *csep << endl;
|
||||
cerr << "-------------- EXECUTION PLAN END --------------\n" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,9 @@ template <typename T>
|
||||
std::optional<FilterRangeBounds<T>> populateRangeBounds(Histogram_json_hb* columnStatistics)
|
||||
{
|
||||
FilterRangeBounds<T> bounds;
|
||||
// bounds.push_back({0, 6200000});
|
||||
|
||||
// return bounds;
|
||||
|
||||
// TODO configurable parallel factor via session variable
|
||||
// NB now histogram size is the way to control parallel factor with 16 being the maximum
|
||||
@@ -395,9 +398,9 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
|
||||
// add new SC
|
||||
auto& [newTableAlias, colPosition] = tableAliasIt->second;
|
||||
auto newSC = boost::make_shared<execplan::SimpleColumn>(*rc, rc->sessionID());
|
||||
newSC->tableName("");
|
||||
newSC->schemaName("");
|
||||
newSC->tableAlias(newTableAlias);
|
||||
newSC->tableAlias(newTableAlias);
|
||||
newSC->alias(rc->alias());
|
||||
|
||||
auto* sc = dynamic_cast<execplan::SimpleColumn*>(rc.get());
|
||||
@@ -408,14 +411,16 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
|
||||
if (it == SCAliasToPosCounterMap.end())
|
||||
{
|
||||
SCAliasToPosCounterMap.insert({sc->columnName(), currentColPosition++});
|
||||
colPosition++;
|
||||
std::cout << " first case new column in the map colPosition " << SCAliasToPosCounterMap[sc->columnName()] << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << " first case reusing column from the map colPosition " << SCAliasToPosCounterMap[sc->columnName()] << std::endl;
|
||||
}
|
||||
assert(SCAliasToPosCounterMap[sc->columnName()] == colPosition);
|
||||
assert(SCAliasToPosCounterMap[sc->columnName()] == colPosition-1);
|
||||
newSC->colPosition(SCAliasToPosCounterMap[sc->columnName()]);
|
||||
sc->derivedTable(newTableAlias);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -445,9 +450,10 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
|
||||
if (tableAliasIt != tableAliasMap.end())
|
||||
{
|
||||
auto& [newTableAlias, colPosition] = tableAliasIt->second;
|
||||
sc->tableName("");
|
||||
sc->schemaName("");
|
||||
sc->tableName(newTableAlias);
|
||||
sc->tableAlias(newTableAlias);
|
||||
sc->derivedTable(newTableAlias);
|
||||
|
||||
auto& [unused, SCAliasToPosCounterMap, currentColPosition] = tableAliasToSCPositionsIt->second;
|
||||
auto it = SCAliasToPosCounterMap.find(sc->columnName());
|
||||
@@ -463,6 +469,7 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
|
||||
assert(SCAliasToPosCounterMap[sc->columnName()] == colPosition);
|
||||
sc->colPosition(SCAliasToPosCounterMap[sc->columnName()]);
|
||||
// sc->colPosition(colPosition++);
|
||||
colPosition++;
|
||||
}
|
||||
// do nothing with this SC
|
||||
}
|
||||
@@ -472,7 +479,6 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
|
||||
// Remove the filters that are not necessary as they were pushed down to union units.
|
||||
// But this is inappropriate for some EXISTS filter and join conditions
|
||||
|
||||
// WIP hardcoded query with lhs,rhs being simple columns
|
||||
auto filters = csep.filters();
|
||||
|
||||
if (filters)
|
||||
@@ -498,42 +504,14 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
|
||||
}
|
||||
sc->colPosition(SCAliasToPosCounterMap[sc->columnName()]);
|
||||
|
||||
sc->tableName("");
|
||||
sc->schemaName("");
|
||||
sc->tableName(newTableAlias);
|
||||
sc->derivedTable(newTableAlias);
|
||||
sc->tableAlias(newTableAlias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (csep.filters() && csep.filters()->data())
|
||||
// {
|
||||
// auto* left = dynamic_cast<execplan::SimpleFilter*>(csep.filters()->data());
|
||||
// if (left)
|
||||
// {
|
||||
// auto* lhs = left->lhs()->clone();
|
||||
// if (lhs)
|
||||
// {
|
||||
// auto* lhsSC = dynamic_cast<execplan::SimpleColumn*>(lhs);
|
||||
// if (lhsSC)
|
||||
// {
|
||||
// auto newTableAlias =
|
||||
// tableAliasMap.find({lhsSC->schemaName(), lhsSC->tableName(), lhsSC->tableAlias(), "", false});
|
||||
// // WIP Leak loosing previous lhs
|
||||
// if (newTableAlias != tableAliasMap.end())
|
||||
// {
|
||||
// lhsSC->tableName("");
|
||||
// lhsSC->schemaName("");
|
||||
// lhsSC->tableAlias(newTableAlias->second.first);
|
||||
// lhsSC->colPosition(0);
|
||||
// left->lhs(lhs);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
csep.derivedTableList(newDerivedTableList);
|
||||
// Replace table list with new table list populated with union units
|
||||
csep.tableList(newTableList);
|
||||
|
||||
25
mysql-test/columnstore/future/MCOL-6072-qa.test
Normal file
25
mysql-test/columnstore/future/MCOL-6072-qa.test
Normal file
@@ -0,0 +1,25 @@
|
||||
# For manual usage only!
|
||||
|
||||
select l_orderkey,l_suppkey from lineitem limit 10;
|
||||
select l_suppkey,l_orderkey from (select l_suppkey,l_orderkey from lineitem limit 10) s1;
|
||||
|
||||
select s1.* from (select l_suppkey+1 as ho,l_orderkey+1 as mo from lineitem limit 10) s1;
|
||||
select mo,ho from (select l_suppkey+1 as ho,l_orderkey+1 as mo from lineitem limit 10) s1;
|
||||
|
||||
select nl.l_suppkey,lineitem.l_suppkey from lineitem,lineitem_10rows nl WHERE lineitem.l_suppkey=nl.l_suppkey limit 10;
|
||||
|
||||
select nl.l_orderkey,l.l_suppkey,nl.l_suppkey,l.l_suppkey from lineitem l,lineitem_10rows nl WHERE l.l_suppkey=nl.l_suppkey limit 10;
|
||||
# test set with join
|
||||
select nl.l_orderkey,l.l_suppkey,nl.l_suppkey,l.l_orderkey from lineitem l,lineitem_10rows nl WHERE l.l_suppkey=nl.l_suppkey limit 10;
|
||||
|
||||
select nl.l_orderkey,l.l_suppkey,nl.l_suppkey,l.l_orderkey from (select l_orderkey,l_suppkey from lineitem) l,lineitem_10rows nl WHERE l.l_suppkey=nl.l_suppkey limit 10;
|
||||
select * from (select l_orderkey,l_suppkey+1 from lineitem limit 10) sa where sa.l_orderkey = 1999905;
|
||||
|
||||
|
||||
elect nl.l_orderkey,l.l_suppkey,nl.l_suppkey,l.l_orderkey from (select l_orderkey,l_suppkey from lineitem) l,(select l_orderkey,l_suppkey from lineitem_10rows) nl WHERE l.l_suppkey=nl.l_suppkey limit 10;
|
||||
|
||||
|
||||
select nl.l_orderkey,l.l_suppkey+1 from lineitem l,lineitem_10rows nl WHERE l.l_suppkey=nl.l_suppkey limit 10
|
||||
|
||||
select nl.l_suppkey,lineitem.l_suppkey from lineitem,lineitem_10rows nl WHERE lineitem.l_suppkey=nl.l_suppkey AND lineitem.l_suppkey = 25 limit 10;
|
||||
|
||||
Reference in New Issue
Block a user