27
27
class CandidatePlanCharacter;
30
* An interface for policies overriding the query optimizer's default query plan selection
30
* An interface for policies overriding the query optimizer's default behavior for selecting
31
* query plans and creating cursors.
33
33
class QueryPlanSelectionPolicy {
37
37
virtual bool permitOptimalNaturalPlan() const { return true; }
38
38
virtual bool permitOptimalIdPlan() const { return true; }
39
39
virtual bool permitPlan( const QueryPlan &plan ) const { return true; }
40
virtual BSONObj planHint( const char *ns ) const { return BSONObj(); }
40
virtual BSONObj planHint( const StringData& ns ) const { return BSONObj(); }
43
* @return true to request that a created Cursor provide a matcher(). If false, the
44
* Cursor's matcher() may be NULL if the Cursor can perform accurate query matching
45
* internally using a non Matcher mechanism. One case where a Matcher might be requested
46
* even though not strictly necessary to select matching documents is if metadata about
47
* matches may be requested using MatchDetails. NOTE This is a hint that the Cursor use a
48
* Matcher, but the hint may be ignored. In some cases the Cursor may not provide
49
* a Matcher even if 'requestMatcher' is true.
51
virtual bool requestMatcher() const { return true; }
54
* @return true to request creating an IntervalBtreeCursor rather than a BtreeCursor when
55
* possible. An IntervalBtreeCursor is optimized for counting the number of documents
56
* between two endpoints in a btree. NOTE This is a hint to create an interval cursor, but
57
* the hint may be ignored. In some cases a different cursor type may be created even if
58
* 'requestIntervalCursor' is true.
60
virtual bool requestIntervalCursor() const { return false; }
42
62
/** Allow any query plan selection, permitting the query optimizer's default behavior. */
43
63
static const QueryPlanSelectionPolicy &any();
77
97
virtual string name() const { return "idElseNatural"; }
78
98
virtual bool permitPlan( const QueryPlan &plan ) const;
79
virtual BSONObj planHint( const char *ns ) const;
99
virtual BSONObj planHint( const StringData& ns ) const;
82
102
class FieldRangeSet;