summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2013-12-09 12:27:13 -0500
committerMathias Stearn <mathias@10gen.com>2013-12-18 19:09:17 -0500
commit3e707bcd22b7c0e8275d25bf8e8b28c3cec4cc67 (patch)
treea7a30fbd405d54199721616f4d2854231deff3d6 /src/mongo/db
parent54cee6c07af4c2973f34b25de271f7258dafbc84 (diff)
downloadmongo-3e707bcd22b7c0e8275d25bf8e8b28c3cec4cc67.tar.gz
SERVER-11831 Use documentFromBsonWithDeps in agg again
This bypasses new query framework projection and replaces it with a much faster dedicated code path. The downside is that it prevents using covering indexes in the cases where that was allowed (SERVER-12015).
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/pipeline/document_source.h1
-rw-r--r--src/mongo/db/pipeline/document_source_cursor.cpp13
-rw-r--r--src/mongo/db/pipeline/pipeline_d.cpp6
3 files changed, 15 insertions, 5 deletions
diff --git a/src/mongo/db/pipeline/document_source.h b/src/mongo/db/pipeline/document_source.h
index d0148be0bf5..f3b282182a0 100644
--- a/src/mongo/db/pipeline/document_source.h
+++ b/src/mongo/db/pipeline/document_source.h
@@ -422,6 +422,7 @@ namespace mongo {
BSONObj _query;
BSONObj _sort;
BSONObj _projection;
+ bool _haveDeps;
ParsedDeps _dependencies;
intrusive_ptr<DocumentSourceLimit> _limit;
long long _docsAddedToBatches; // for _limit enforcement
diff --git a/src/mongo/db/pipeline/document_source_cursor.cpp b/src/mongo/db/pipeline/document_source_cursor.cpp
index 324d83e3236..bba5ab951fe 100644
--- a/src/mongo/db/pipeline/document_source_cursor.cpp
+++ b/src/mongo/db/pipeline/document_source_cursor.cpp
@@ -97,9 +97,12 @@ namespace mongo {
BSONObj obj;
Runner::RunnerState state;
while ((state = runner->getNext(&obj, NULL)) == Runner::RUNNER_ADVANCED) {
- // TODO SERVER-11831: consider using documentFromBsonWithDeps(obj, _dependencies)
-
- _currentBatch.push_back(Document(obj));
+ if (_haveDeps) {
+ _currentBatch.push_back(documentFromBsonWithDeps(obj, _dependencies));
+ }
+ else {
+ _currentBatch.push_back(Document(obj));
+ }
if (_limit) {
if (++_docsAddedToBatches == _limit->getLimit()) {
@@ -178,8 +181,10 @@ namespace {
if (info->isScanAndOrderSet())
out[TypeExplain::scanAndOrder()] = Value(info->getScanAndOrder());
+#if 0 // Disabled pending SERVER-12015 since until then no aggs will be index only.
if (info->isIndexOnlySet())
out[TypeExplain::indexOnly()] = Value(info->getIndexOnly());
+#endif
if (info->isIndexBoundsSet())
out[TypeExplain::indexBounds()] = Value(info->getIndexBounds());
@@ -250,6 +255,7 @@ namespace {
CursorId cursorId,
const intrusive_ptr<ExpressionContext> &pCtx)
: DocumentSource(pCtx)
+ , _haveDeps(false)
, _docsAddedToBatches(0)
, _ns(ns)
, _cursorId(cursorId)
@@ -265,5 +271,6 @@ namespace {
void DocumentSourceCursor::setProjection(const BSONObj& projection, const ParsedDeps& deps) {
_projection = projection;
_dependencies = deps;
+ _haveDeps = true;
}
}
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp
index c3a9e1b8e8f..130cd87d01a 100644
--- a/src/mongo/db/pipeline/pipeline_d.cpp
+++ b/src/mongo/db/pipeline/pipeline_d.cpp
@@ -184,10 +184,12 @@ namespace {
bool sortInRunner = false;
if (sortStage) {
CanonicalQuery* cq;
+ // Passing an empty projection since it is faster to use documentFromBsonWithDeps.
+ // This will need to change to support covering indexes (SERVER-12015).
uassertStatusOK(CanonicalQuery::canonicalize(pExpCtx->ns,
queryObj,
sortObj,
- projection,
+ BSONObj(), // projection
&cq));
Runner* rawRunner;
if (getRunner(cq, &rawRunner, runnerOptions).isOK()) {
@@ -209,7 +211,7 @@ namespace {
uassertStatusOK(CanonicalQuery::canonicalize(pExpCtx->ns,
queryObj,
noSort,
- projection,
+ BSONObj(), // projection
&cq));
Runner* rawRunner;