summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_planner_params.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/query_planner_params.h')
-rw-r--r--src/mongo/db/query/query_planner_params.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/query/query_planner_params.h b/src/mongo/db/query/query_planner_params.h
index 4b8a5f54904..806456f0508 100644
--- a/src/mongo/db/query/query_planner_params.h
+++ b/src/mongo/db/query/query_planner_params.h
@@ -103,6 +103,23 @@ struct QueryPlannerParams {
// Set this to track the most recent timestamp seen by this cursor while scanning the oplog.
TRACK_LATEST_OPLOG_TS = 1 << 12,
+
+ // Instruct the plan enumerator to enumerate contained $ors in a special order. $or
+ // enumeration can generate an exponential number of plans, and is therefore limited at some
+ // arbitrary cutoff controlled by a parameter. When this limit is hit, the order of
+ // enumeration is important. For example, a query like the following has a "contained $or"
+ // (within an $and):
+ // {a: 1, $or: [{b: 1, c: 1}, {b: 2, c: 2}]}
+ // For this query if there are indexes a_b={a: 1, b: 1} and a_c={a: 1, c: 1}, the normal
+ // enumeration order would output assignments [a_b, a_b], [a_c, a_b], [a_b, a_c], then [a_c,
+ // a_c]. This flag will instruct the enumerator to instead prefer a different order. It's
+ // hard to summarize, but perhaps the phrases "lockstep enumeration", "simultaneous
+ // advancement", or "parallel iteration" will help the reader. The effect is to give earlier
+ // enumeration to plans which use the same index of alternative across all branches. In this
+ // order, we would get assignments [a_b, a_b], [a_c, a_c], [a_c, a_b], then [a_b, a_c]. This
+ // is thought to be helpful in general, but particularly in cases where all children of the
+ // $or use the same fields and have the same indexes available, as in this example.
+ ENUMERATE_OR_CHILDREN_LOCKSTEP = 1 << 13,
};
// See Options enum above.