1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-11-03 17:13:17 +03:00

fix(rbo,rules): MCOL-6131 predicate pushdown rule for RBO.

This commit is contained in:
drrtuy
2025-08-07 17:26:13 +00:00
committed by Leonid Fedorov
parent 1341d282ad
commit 67ac7f2f75
6 changed files with 294 additions and 218 deletions

View File

@@ -50,9 +50,17 @@ bool optimizeCSEPWithRules(execplan::CalpontSelectExecutionPlan& root, const std
// high level API call for optimizer
bool optimizeCSEP(execplan::CalpontSelectExecutionPlan& root, optimizer::RBOptimizerContext& ctx)
{
optimizer::Rule parallelCES{"parallelCES", optimizer::matchParallelCES, optimizer::applyParallelCES};
std::vector<optimizer::Rule> rules;
std::vector<optimizer::Rule> rules = {parallelCES};
if (get_unstable_optimizer(&ctx.thd))
{
optimizer::Rule parallelCES{"parallelCES", optimizer::matchParallelCES, optimizer::applyParallelCES};
rules.push_back(parallelCES);
}
optimizer::Rule predicatePushdown{"predicatePushdown", optimizer::matchParallelCES,
optimizer::applyParallelCES};
rules.push_back(predicatePushdown);
return optimizeCSEPWithRules(root, rules, ctx);
}
@@ -85,6 +93,7 @@ bool Rule::walk(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBOptimiz
execplan::CalpontSelectExecutionPlan* current = planStack.top();
planStack.pop();
// Walk nested derived
for (auto& table : current->derivedTableList())
{
auto* csepPtr = dynamic_cast<execplan::CalpontSelectExecutionPlan*>(table.get());
@@ -94,6 +103,7 @@ bool Rule::walk(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBOptimiz
}
}
// Walk nested UNION UNITS
for (auto& unionUnit : current->unionVec())
{
auto* unionUnitPtr = dynamic_cast<execplan::CalpontSelectExecutionPlan*>(unionUnit.get());
@@ -103,6 +113,18 @@ bool Rule::walk(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBOptimiz
}
}
// Walk nested subselect in filters, e.g. SEMI-JOIN
for (auto& subselect : csep.subSelectList())
{
auto* subselectPtr = dynamic_cast<execplan::CalpontSelectExecutionPlan*>(subselect.get());
if (subselectPtr)
{
planStack.push(subselectPtr);
}
}
// TODO add walking nested subselect in projection. See CSEP::fSelectSubList
if (matchRule(*current))
{
applyRule(*current, ctx);