diff --git a/dbcon/mysql/ha_mcs_execplan.cpp b/dbcon/mysql/ha_mcs_execplan.cpp index 0984073d6..e143a38ec 100644 --- a/dbcon/mysql/ha_mcs_execplan.cpp +++ b/dbcon/mysql/ha_mcs_execplan.cpp @@ -7610,14 +7610,6 @@ 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; } diff --git a/dbcon/mysql/rbo_apply_parallel_ces.cpp b/dbcon/mysql/rbo_apply_parallel_ces.cpp index 53b04aa87..e7a631042 100644 --- a/dbcon/mysql/rbo_apply_parallel_ces.cpp +++ b/dbcon/mysql/rbo_apply_parallel_ces.cpp @@ -208,9 +208,6 @@ template std::optional> populateRangeBounds(Histogram_json_hb* columnStatistics) { FilterRangeBounds 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 @@ -257,56 +254,56 @@ execplan::CalpontSelectExecutionPlan::SelectList makeUnionFromTable( execplan::CalpontSelectExecutionPlan& csep, execplan::CalpontSystemCatalog::TableAliasName& table, optimizer::RBOptimizerContext& ctx) { -execplan::CalpontSelectExecutionPlan::SelectList unionVec; + execplan::CalpontSelectExecutionPlan::SelectList unionVec; -// SC type controls an integral type used to produce suitable filters. The continuation of this function -// should become a template function based on SC type. -auto keyColumnAndStatistics = chooseKeyColumnAndStatistics(table, ctx); -if (!keyColumnAndStatistics) -{ - return unionVec; -} + // SC type controls an integral type used to produce suitable filters. The continuation of this function + // should become a template function based on SC type. + auto keyColumnAndStatistics = chooseKeyColumnAndStatistics(table, ctx); + if (!keyColumnAndStatistics) + { + return unionVec; + } -auto& [keyColumn, columnStatistics] = keyColumnAndStatistics.value(); + auto& [keyColumn, columnStatistics] = keyColumnAndStatistics.value(); -std::cout << "makeUnionFromTable keyColumn " << keyColumn.toString() << std::endl; -std::cout << "makeUnionFromTable RC front " << csep.returnedCols().front()->toString() << std::endl; + std::cout << "makeUnionFromTable keyColumn " << keyColumn.toString() << std::endl; + std::cout << "makeUnionFromTable RC front " << csep.returnedCols().front()->toString() << std::endl; -// TODO char and other numerical types support -auto boundsOpt = populateRangeBounds(columnStatistics); -if (!boundsOpt.has_value()) -{ - return unionVec; -} + // TODO char and other numerical types support + auto boundsOpt = populateRangeBounds(columnStatistics); + if (!boundsOpt.has_value()) + { + return unionVec; + } -auto& bounds = boundsOpt.value(); + auto& bounds = boundsOpt.value(); -// These bounds produce low <= col < high -if (bounds.size() > 1) -{ - for (size_t i = 0; i <= bounds.size() - 2; ++i) + // These bounds produce low <= col < high + if (bounds.size() > 1) + { + for (size_t i = 0; i <= bounds.size() - 2; ++i) + { + auto clonedCSEP = csep.cloneForTableWORecursiveSelectsGbObHaving(table); + // Add BETWEEN based on key column range + auto filter = filtersWithNewRange(clonedCSEP, keyColumn, bounds[i], false); + clonedCSEP->filters(filter); + // To create CES filter we need to have a column in the column map + clonedCSEP->columnMap().insert({keyColumn.columnName(), execplan::SRCP(keyColumn.clone())}); + unionVec.push_back(clonedCSEP); + } + } + // This last bound produces low <= col <= high + // TODO add NULLs into filter of the last step + if (!bounds.empty()) { auto clonedCSEP = csep.cloneForTableWORecursiveSelectsGbObHaving(table); - // Add BETWEEN based on key column range - auto filter = filtersWithNewRange(clonedCSEP, keyColumn, bounds[i], false); - clonedCSEP->filters(filter); - // To create CES filter we need to have a column in the column map + auto filter = filtersWithNewRange(clonedCSEP, keyColumn, bounds.back(), true); clonedCSEP->columnMap().insert({keyColumn.columnName(), execplan::SRCP(keyColumn.clone())}); + clonedCSEP->filters(filter); unionVec.push_back(clonedCSEP); } -} -// This last bound produces low <= col <= high -// TODO add NULLs into filter of the last step -if (!bounds.empty()) -{ - auto clonedCSEP = csep.cloneForTableWORecursiveSelectsGbObHaving(table); - auto filter = filtersWithNewRange(clonedCSEP, keyColumn, bounds.back(), true); - clonedCSEP->columnMap().insert({keyColumn.columnName(), execplan::SRCP(keyColumn.clone())}); - clonedCSEP->filters(filter); - unionVec.push_back(clonedCSEP); -} -return unionVec; + return unionVec; } execplan::SCSEP createDerivedTableFromTable(