diff options
author | Hari Khalsa <hkhalsa@10gen.com> | 2013-09-30 21:32:58 -0400 |
---|---|---|
committer | Hari Khalsa <hkhalsa@10gen.com> | 2013-10-01 22:37:37 -0400 |
commit | 3b14e72704f640aff26385142d1aa61666e912fc (patch) | |
tree | 4933dcaac8bfdfd9f60f883f85cd24106c10dbe1 /src/mongo/db/query/query_planner.h | |
parent | d423807c7b136c0d74e83fd45e3701c37b799506 (diff) | |
download | mongo-3b14e72704f640aff26385142d1aa61666e912fc.tar.gz |
SERVER-10471 multikey correctness, fix compound idxs, a few bug fixes
Diffstat (limited to 'src/mongo/db/query/query_planner.h')
-rw-r--r-- | src/mongo/db/query/query_planner.h | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/mongo/db/query/query_planner.h b/src/mongo/db/query/query_planner.h index 1d8d47091a2..2224c30f0e6 100644 --- a/src/mongo/db/query/query_planner.h +++ b/src/mongo/db/query/query_planner.h @@ -29,6 +29,7 @@ #pragma once #include "mongo/db/query/canonical_query.h" +#include "mongo/db/query/index_entry.h" #include "mongo/db/query/query_solution.h" namespace mongo { @@ -39,6 +40,15 @@ namespace mongo { */ class QueryPlanner { public: + enum Options { + // You probably want to set this. + DEFAULT = 0, + + // Set this if you don't want a table scan. + // See http://docs.mongodb.org/manual/reference/parameters/ + NO_TABLE_SCAN = 1, + }; + /** * Outputs a series of possible solutions for the provided 'query' into 'out'. Uses the * provided indices to generate a solution. @@ -46,7 +56,8 @@ namespace mongo { * Caller owns pointers in *out. */ static void plan(const CanonicalQuery& query, - const vector<BSONObj>& indexKeyPatterns, + const vector<IndexEntry>& indices, + size_t options, vector<QuerySolution*>* out); private: @@ -68,21 +79,21 @@ namespace mongo { * useful in answering the query. */ static void findRelevantIndices(const unordered_set<string>& fields, - const vector<BSONObj>& allIndices, - vector<BSONObj>* out); + const vector<IndexEntry>& indices, + vector<IndexEntry>* out); /** - * Return true if the index key pattern field 'elt' can be used to answer the predicate - * 'node'. + * Return true if the index key pattern field 'elt' (which belongs to 'index') can be used + * to answer the predicate 'node'. * * For example, {field: "hashed"} can only be used with sets of equalities. * {field: "2d"} can only be used with some geo predicates. * {field: "2dsphere"} can only be used with some other geo predicates. */ - static bool compatible(const BSONElement& elt, MatchExpression* node); + static bool compatible(const BSONElement& elt, const IndexEntry& index, MatchExpression* node); /** - * Determine how useful all of our relevant indices are to all predicates in the subtree + * Determine how useful all of our relevant 'indices' are to all predicates in the subtree * rooted at 'node'. Affixes a RelevantTag to all predicate nodes which can use an index. * * 'prefix' is a path prefix that should be prepended to any path (certain array operators @@ -97,7 +108,7 @@ namespace mongo { * original predicate by having an AND as a parent. */ static void rateIndices(MatchExpression* node, string prefix, - const vector<BSONObj>& indices); + const vector<IndexEntry>& indices); // // Collection Scan Data Access method. @@ -114,7 +125,7 @@ namespace mongo { // The inArrayOperator flag deserves some attention. It is set when we're processing a child of // a MatchExpression::ALL or MatchExpression::ELEM_MATCH_OBJECT. // - // Behavior changes for all methods below that take it as an argument: + // When true, the following behavior changes for all methods below that take it as an argument: // 0. No deletion of MatchExpression(s). In fact, // 1. No mutation of the MatchExpression at all. We need the tree as-is in order to perform // a filter on the entire tree. @@ -129,21 +140,21 @@ namespace mongo { */ static QuerySolutionNode* buildIndexedDataAccess(MatchExpression* root, bool inArrayOperator, - const vector<BSONObj>& indexKeyPatterns); + const vector<IndexEntry>& indices); /** * Takes ownership of 'root'. */ static QuerySolutionNode* buildIndexedAnd(MatchExpression* root, bool inArrayOperator, - const vector<BSONObj>& indexKeyPatterns); + const vector<IndexEntry>& indices); /** * Takes ownership of 'root'. */ static QuerySolutionNode* buildIndexedOr(MatchExpression* root, bool inArrayOperator, - const vector<BSONObj>& indexKeyPatterns); + const vector<IndexEntry>& indices); /** * Helper used by buildIndexedAnd and buildIndexedOr. @@ -160,7 +171,7 @@ namespace mongo { */ static bool processIndexScans(MatchExpression* root, bool inArrayOperator, - const vector<BSONObj>& indexKeyPatterns, + const vector<IndexEntry>& indices, vector<QuerySolutionNode*>* out); // |