diff options
author | Matt Boros <matt.boros@mongodb.com> | 2022-06-10 19:34:42 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-10 20:22:54 +0000 |
commit | 00d2a56763b2b0da941a41684d20e7080da5058e (patch) | |
tree | ca0e92620a220e1581632e3846e5f14790c78f8f /src/mongo/db/query/query_planner_params.h | |
parent | 5b0d49742e1dd9462262593fe844bf3e65bca1d7 (diff) | |
download | mongo-00d2a56763b2b0da941a41684d20e7080da5058e.tar.gz |
SERVER-64994 Extend the planner to allow soft hints about index traversal direction
Diffstat (limited to 'src/mongo/db/query/query_planner_params.h')
-rw-r--r-- | src/mongo/db/query/query_planner_params.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mongo/db/query/query_planner_params.h b/src/mongo/db/query/query_planner_params.h index af643a632c8..3a7dc82c79f 100644 --- a/src/mongo/db/query/query_planner_params.h +++ b/src/mongo/db/query/query_planner_params.h @@ -58,9 +58,24 @@ struct SecondaryCollectionInfo { long long storageSizeBytes{0}; }; + +// This holds information about the internal traversal preference used for time series. If we choose +// an index that involves fields we're interested in, we prefer a specific direction to avoid a +// blocking sort. +struct TraversalPreference { + // If we end up with an index that provides {sortPattern}, we prefer to scan it in direction + // {direction}. + BSONObj sortPattern; + int direction; + // Cluster key for the collection this query accesses (for time-series it's control.min.time). + // If a collection scan is chosen, this will be compared against the sortPattern to see if we + // can satisfy the traversal preference. + std::string clusterField; +}; + struct QueryPlannerParams { - QueryPlannerParams() - : options(DEFAULT), + QueryPlannerParams(size_t options = DEFAULT) + : options(options), indexFiltersApplied(false), maxIndexedSolutions(internalQueryPlannerMaxIndexedSolutions.load()), clusteredCollectionCollator(nullptr) {} @@ -178,6 +193,8 @@ struct QueryPlannerParams { // List of information about any secondary collections that can be executed against. std::map<NamespaceString, SecondaryCollectionInfo> secondaryCollectionsInfo; + + boost::optional<TraversalPreference> traversalPreference = boost::none; }; } // namespace mongo |