summaryrefslogtreecommitdiff
path: root/src/mongo/db/index
diff options
context:
space:
mode:
authorZhihui Fan <yizhi.fzh@alibaba-inc.com>2020-02-04 08:09:01 +0800
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-22 16:47:37 +0000
commitbad7c538e7efbc996a6089e1569681edf24e6b33 (patch)
tree07aa2c5b48062ed36d147a682f06beeb4d6f9f69 /src/mongo/db/index
parent17edea396d470d0ddc258674feba030ffafbffe8 (diff)
downloadmongo-bad7c538e7efbc996a6089e1569681edf24e6b33.tar.gz
SERVER-9306 Ability to temporarily forbid query optimizer from using index ("Hidden Index") SERVER-47275 Take over and complete Hidden Indexes PR
Co-authored-by: Ruoxin Xu <ruoxin.xu@mongodb.com>
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r--src/mongo/db/index/index_descriptor.cpp5
-rw-r--r--src/mongo/db/index/index_descriptor.h6
2 files changed, 10 insertions, 1 deletions
diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp
index 248e87e8b91..17f765d87cf 100644
--- a/src/mongo/db/index/index_descriptor.cpp
+++ b/src/mongo/db/index/index_descriptor.cpp
@@ -61,7 +61,8 @@ void populateOptionsMap(std::map<StringData, BSONElement>& theMap, const BSONObj
IndexDescriptor::kBackgroundFieldName || // this is a creation time option only
fieldName == IndexDescriptor::kDropDuplicatesFieldName || // this is now ignored
fieldName == IndexDescriptor::kSparseFieldName || // checked specially
- fieldName == IndexDescriptor::kUniqueFieldName // check specially
+ fieldName == IndexDescriptor::kHiddenFieldName || // not considered for equivalence
+ fieldName == IndexDescriptor::kUniqueFieldName // check specially
) {
continue;
}
@@ -93,6 +94,7 @@ constexpr StringData IndexDescriptor::kSparseFieldName;
constexpr StringData IndexDescriptor::kStorageEngineFieldName;
constexpr StringData IndexDescriptor::kTextVersionFieldName;
constexpr StringData IndexDescriptor::kUniqueFieldName;
+constexpr StringData IndexDescriptor::kHiddenFieldName;
constexpr StringData IndexDescriptor::kWeightsFieldName;
IndexDescriptor::IndexDescriptor(Collection* collection,
@@ -109,6 +111,7 @@ IndexDescriptor::IndexDescriptor(Collection* collection,
_isIdIndex(isIdIndexPattern(_keyPattern)),
_sparse(infoObj[IndexDescriptor::kSparseFieldName].trueValue()),
_unique(_isIdIndex || infoObj[kUniqueFieldName].trueValue()),
+ _hidden(infoObj[kHiddenFieldName].trueValue()),
_partial(!infoObj[kPartialFilterExprFieldName].eoo()),
_cachedEntry(nullptr) {
BSONElement e = _infoObj[IndexDescriptor::kIndexVersionFieldName];
diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h
index b8d61b20564..4eab168a65a 100644
--- a/src/mongo/db/index/index_descriptor.h
+++ b/src/mongo/db/index/index_descriptor.h
@@ -82,6 +82,7 @@ public:
static constexpr StringData kStorageEngineFieldName = "storageEngine"_sd;
static constexpr StringData kTextVersionFieldName = "textIndexVersion"_sd;
static constexpr StringData kUniqueFieldName = "unique"_sd;
+ static constexpr StringData kHiddenFieldName = "hidden"_sd;
static constexpr StringData kWeightsFieldName = "weights"_sd;
/**
@@ -174,6 +175,10 @@ public:
return _unique;
}
+ bool hidden() const {
+ return _hidden;
+ }
+
// Is this index sparse?
bool isSparse() const {
return _sparse;
@@ -255,6 +260,7 @@ private:
bool _isIdIndex;
bool _sparse;
bool _unique;
+ bool _hidden;
bool _partial;
IndexVersion _version;
BSONObj _collation;