summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_planner.h
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2013-11-08 16:21:29 -0500
committerHari Khalsa <hkhalsa@10gen.com>2013-11-09 18:20:08 -0500
commit3256b1812830868858753b361939b5deb084dee5 (patch)
tree3926fb31ae417f7ab3fde357e370947d41ffb42d /src/mongo/db/query/query_planner.h
parent8763f2868b3c1470ebfdb8490370c7cb1ee40301 (diff)
downloadmongo-3256b1812830868858753b361939b5deb084dee5.tar.gz
SERVER-10026 perform shard filtering as a data access stage
Diffstat (limited to 'src/mongo/db/query/query_planner.h')
-rw-r--r--src/mongo/db/query/query_planner.h43
1 files changed, 31 insertions, 12 deletions
diff --git a/src/mongo/db/query/query_planner.h b/src/mongo/db/query/query_planner.h
index f470132823e..4e12bb38264 100644
--- a/src/mongo/db/query/query_planner.h
+++ b/src/mongo/db/query/query_planner.h
@@ -34,12 +34,7 @@
namespace mongo {
- /**
- * QueryPlanner's job is to provide an entry point to the query planning and optimization
- * process.
- */
- class QueryPlanner {
- public:
+ struct QueryPlannerParams {
enum Options {
// You probably want to set this.
DEFAULT = 0,
@@ -50,17 +45,38 @@ namespace mongo {
// Set this if you want a collscan outputted even if there's an ixscan.
INCLUDE_COLLSCAN = 2,
+
+ // Set this if you're running on a sharded cluster. We'll add a "drop all docs that
+ // shouldn't be on this shard" stage before projection.
+ INCLUDE_SHARD_FILTER = 4,
};
+ // See Options enum above.
+ size_t options;
+
+ // What indices are available for planning?
+ vector<IndexEntry> indices;
+
+ // What's our shard key? If INCLUDE_SHARD_FILTER is set we will create a shard filtering
+ // stage. If we know the shard key, we can perform covering analysis instead of always
+ // forcing a fetch.
+ BSONObj shardKey;
+ };
+
+ /**
+ * QueryPlanner's job is to provide an entry point to the query planning and optimization
+ * process.
+ */
+ class QueryPlanner {
+ public:
/**
* Outputs a series of possible solutions for the provided 'query' into 'out'. Uses the
- * provided indices to generate a solution.
+ * indices and other data in 'params' to plan with.
*
* Caller owns pointers in *out.
*/
static void plan(const CanonicalQuery& query,
- const vector<IndexEntry>& indices,
- size_t options,
+ const QueryPlannerParams& params,
vector<QuerySolution*>* out);
private:
@@ -120,7 +136,9 @@ namespace mongo {
/**
* Return a CollectionScanNode that scans as requested in 'query'.
*/
- static QuerySolution* makeCollectionScan(const CanonicalQuery& query, bool tailable, size_t options);
+ static QuerySolution* makeCollectionScan(const CanonicalQuery& query,
+ bool tailable,
+ const QueryPlannerParams& params);
//
// Indexed Data Access methods.
@@ -232,14 +250,15 @@ namespace mongo {
* Caller owns the returned QuerySolution.
*/
static QuerySolution* analyzeDataAccess(const CanonicalQuery& query,
- size_t options,
+ const QueryPlannerParams& params,
QuerySolutionNode* solnRoot);
/**
* Return a plan that uses the provided index as a proxy for a collection scan.
*/
- static QuerySolution* scanWholeIndex(const IndexEntry& index, size_t options,
+ static QuerySolution* scanWholeIndex(const IndexEntry& index,
const CanonicalQuery& query,
+ const QueryPlannerParams& params,
int direction = 1);
/**