You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
feat(optimizer): add session switch to optionally enable optimizer
This commit is contained in:
@ -21,36 +21,52 @@
|
||||
|
||||
namespace optimizer {
|
||||
|
||||
bool Rule::apply(execplan::CalpontSelectExecutionPlan& csep)
|
||||
bool optimizeCSEPWithRules(execplan::CalpontSelectExecutionPlan& root, const std::vector<Rule>& rules) {
|
||||
|
||||
bool changed = false;
|
||||
for (const auto& rule : rules)
|
||||
{
|
||||
changed |= rule.apply(root);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool optimizeCSEP(execplan::CalpontSelectExecutionPlan& root)
|
||||
{
|
||||
optimizer::Rule parallelCES{"parallelCES", optimizer::matchParallelCES, optimizer::applyParallelCES};
|
||||
|
||||
std::vector<Rule> rules = {parallelCES};
|
||||
|
||||
return optimizeCSEPWithRules(root, rules);
|
||||
}
|
||||
|
||||
// DFS walk
|
||||
bool Rule::apply(execplan::CalpontSelectExecutionPlan& csep) const
|
||||
{
|
||||
bool rewrite = false;
|
||||
|
||||
for (auto& table : csep.derivedTableList())
|
||||
{
|
||||
auto& csepLocal = *dynamic_cast<execplan::CalpontSelectExecutionPlan*>(table.get());
|
||||
if (matchRule(csepLocal))
|
||||
auto* csepPtr = dynamic_cast<execplan::CalpontSelectExecutionPlan*>(table.get());
|
||||
if (!csepPtr)
|
||||
{
|
||||
applyRule(csepLocal);
|
||||
rewrite = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
rewrite |= apply(csepLocal);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto& csepLocal = *csepPtr;
|
||||
rewrite |= apply(csepLocal);
|
||||
}
|
||||
|
||||
for (auto& unionUnit : csep.unionVec())
|
||||
{
|
||||
auto& unionUnitLocal = *dynamic_cast<execplan::CalpontSelectExecutionPlan*>(unionUnit.get());
|
||||
auto* unionUnitPtr = dynamic_cast<execplan::CalpontSelectExecutionPlan*>(unionUnit.get());
|
||||
if (!unionUnitPtr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (matchRule(unionUnitLocal))
|
||||
{
|
||||
applyRule(unionUnitLocal);
|
||||
rewrite = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
rewrite |= apply(unionUnitLocal);
|
||||
}
|
||||
auto& unionUnitLocal = *unionUnitPtr;
|
||||
rewrite |= apply(unionUnitLocal);
|
||||
}
|
||||
|
||||
if (matchRule(csep))
|
||||
|
Reference in New Issue
Block a user