summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2012-01-16 21:54:07 -0800
committerAaron <aaron@10gen.com>2012-01-16 21:54:07 -0800
commit0b38e1009b7e43b84fd791cfc58bf83fb3c6d0eb (patch)
tree203039cfd9b9699f8cf80ed3848fa15076cb2b62 /db
parent86e26ee445a85c72d16d2864c2f33e4f6dbaa3fd (diff)
downloadmongo-0b38e1009b7e43b84fd791cfc58bf83fb3c6d0eb.tar.gz
SERVER-4665 backport 'ConstraintPresent' constraint type and exclusion of unhelpful recorded plans
Diffstat (limited to 'db')
-rw-r--r--db/queryoptimizer.cpp2
-rw-r--r--db/querypattern.h3
-rw-r--r--db/queryutil.cpp2
3 files changed, 5 insertions, 2 deletions
diff --git a/db/queryoptimizer.cpp b/db/queryoptimizer.cpp
index 692e9fd9b98..71ca6576fc4 100644
--- a/db/queryoptimizer.cpp
+++ b/db/queryoptimizer.cpp
@@ -482,7 +482,7 @@ doneCheckOrder:
}
massert( 10368 , "Unable to locate previously recorded index", p.get() );
- if ( !( _bestGuessOnly && p->scanAndOrderRequired() ) ) {
+ if ( !p->unhelpful() && !( _bestGuessOnly && p->scanAndOrderRequired() ) ) {
_usingPrerecordedPlan = true;
_mayRecordPlan = false;
_plans.push_back( p );
diff --git a/db/querypattern.h b/db/querypattern.h
index d87cc64a5bc..2f7450e5ec2 100644
--- a/db/querypattern.h
+++ b/db/querypattern.h
@@ -36,7 +36,8 @@ namespace mongo {
Equality,
LowerBound,
UpperBound,
- UpperAndLowerBound
+ UpperAndLowerBound,
+ ConstraintPresent
};
bool operator<( const QueryPattern &other ) const;
/** for testing only */
diff --git a/db/queryutil.cpp b/db/queryutil.cpp
index 717eac816b8..ef5ae3a6fdb 100644
--- a/db/queryutil.cpp
+++ b/db/queryutil.cpp
@@ -1007,6 +1007,8 @@ namespace mongo {
qp._fieldTypes[ i->first ] = QueryPattern::UpperBound;
else if ( lower )
qp._fieldTypes[ i->first ] = QueryPattern::LowerBound;
+ else
+ qp._fieldTypes[ i->first ] = QueryPattern::ConstraintPresent;
}
}
qp.setSort( sort );