diff options
author | Bernard Gorman <bernard.gorman@gmail.com> | 2017-09-21 02:22:00 -0400 |
---|---|---|
committer | Bernard Gorman <bernard.gorman@gmail.com> | 2017-09-24 15:59:10 -0400 |
commit | 21f5028d4404ea9584d53bdb81dd63ca8a505d6f (patch) | |
tree | ec6e458b171de330c0e4756603ba95ba3df06834 /src/mongo/db/pipeline/document_source_facet.cpp | |
parent | 280981d3a4cadeb91da9fd69864924e61d7ef99a (diff) | |
download | mongo-21f5028d4404ea9584d53bdb81dd63ca8a505d6f.tar.gz |
SERVER-30399 Add caching for $lookup non-correlated sub-pipeline prefix
Diffstat (limited to 'src/mongo/db/pipeline/document_source_facet.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_facet.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/document_source_facet.cpp b/src/mongo/db/pipeline/document_source_facet.cpp index 3c8cf9db359..c7f82678eb1 100644 --- a/src/mongo/db/pipeline/document_source_facet.cpp +++ b/src/mongo/db/pipeline/document_source_facet.cpp @@ -256,15 +256,19 @@ DocumentSource::StageConstraints DocumentSourceFacet::constraints() const { } DocumentSource::GetDepsReturn DocumentSourceFacet::getDependencies(DepsTracker* deps) const { + const bool scopeHasVariables = pExpCtx->variablesParseState.hasDefinedVariables(); for (auto&& facet : _facets) { auto subDepsTracker = facet.pipeline->getDependencies(deps->getMetadataAvailable()); deps->fields.insert(subDepsTracker.fields.begin(), subDepsTracker.fields.end()); + deps->vars.insert(subDepsTracker.vars.begin(), subDepsTracker.vars.end()); deps->needWholeDocument = deps->needWholeDocument || subDepsTracker.needWholeDocument; deps->setNeedTextScore(deps->getNeedTextScore() || subDepsTracker.getNeedTextScore()); - if (deps->needWholeDocument && deps->getNeedTextScore()) { + // If there are variables defined at this stage's scope, there may be dependencies upon + // them in subsequent pipelines. Keep enumerating. + if (deps->needWholeDocument && deps->getNeedTextScore() && !scopeHasVariables) { break; } } |