diff options
author | David Storch <david.storch@10gen.com> | 2015-04-13 13:46:28 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2015-05-21 17:36:14 -0400 |
commit | 920a48f1ed334efde197cc52c8385ea38c03351e (patch) | |
tree | 18e09c34b668e773dc95d7c7f7367e6b174f1c1a /src/mongo/db/commands | |
parent | 707654e4bb97b02d9d96697c0d3d5005960f1f92 (diff) | |
download | mongo-920a48f1ed334efde197cc52c8385ea38c03351e.tar.gz |
SERVER-17577 query planner now makes use of separate limit and batchSize fields in find command
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r-- | src/mongo/db/commands/find_cmd.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/commands/getmore_cmd.cpp | 3 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index 87f349061d7..3afcaaaf88f 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -210,7 +210,8 @@ namespace mongo { } // Fill out curop information. - beginQueryOp(nss, cmdObj, lpq->getNumToReturn(), lpq->getSkip(), CurOp::get(txn)); + int ntoreturn = lpq->getBatchSize().value_or(0); + beginQueryOp(nss, cmdObj, ntoreturn, lpq->getSkip(), CurOp::get(txn)); // 1b) Finish the parsing step by using the LiteParsedQuery to create a CanonicalQuery. std::unique_ptr<CanonicalQuery> cq; @@ -309,14 +310,11 @@ namespace mongo { BSONObj obj; PlanExecutor::ExecState state; int numResults = 0; - while (PlanExecutor::ADVANCED == (state = exec->getNext(&obj, NULL))) { + while (!enoughForFirstBatch(pq, numResults, firstBatch.len()) + && PlanExecutor::ADVANCED == (state = exec->getNext(&obj, NULL))) { // Add result to output buffer. firstBatch.append(obj); numResults++; - - if (enoughForFirstBatch(pq, numResults, firstBatch.len())) { - break; - } } // Throw an assertion if query execution fails for any reason. diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index 2ae2d54a015..574c7bea6a1 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -346,7 +346,8 @@ namespace mongo { nextBatch->append(obj); (*numResults)++; - if (enoughForGetMore(request.batchSize, *numResults, nextBatch->len())) { + if (enoughForGetMore(request.batchSize.value_or(0), + *numResults, nextBatch->len())) { break; } } |