summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_planner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/query_planner.cpp')
-rw-r--r--src/mongo/db/query/query_planner.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp
index ef51a3f7ba5..26a605c081f 100644
--- a/src/mongo/db/query/query_planner.cpp
+++ b/src/mongo/db/query/query_planner.cpp
@@ -1193,6 +1193,18 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan(
}
}
+ // Check whether we're eligible to use the columnar index, assuming no other indexes can be
+ // used.
+ if (out.empty() && !params.columnarIndexes.empty() && query.getProj() &&
+ !query.getProj()->requiresDocument()) {
+ // TODO SERVER-63123: Check if the columnar index actually provides the fields we need.
+ auto columnScan = std::make_unique<ColumnIndexScanNode>(params.columnarIndexes.front());
+ columnScan->fields = query.getProj()->getRequiredFields();
+ columnScan->filter = query.root()->shallowClone();
+ auto plan = QueryPlannerAnalysis::analyzeDataAccess(query, params, std::move(columnScan));
+ out.push_back(std::move(plan));
+ }
+
// The caller can explicitly ask for a collscan.
bool collscanRequested = (params.options & QueryPlannerParams::INCLUDE_COLLSCAN);