summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2014-12-09 16:16:50 -0500
committerJason Rassi <rassi@10gen.com>2014-12-09 18:17:10 -0500
commit604fc8c629b4cd90a3fbd84e53eb4c892878a318 (patch)
tree0461c3177027c827f0c4d13e44f27b67c4b4326a /src/mongo/db/commands
parentefe368fa7a6b4c1ca6077fdb2560a33dfdc82337 (diff)
downloadmongo-604fc8c629b4cd90a3fbd84e53eb4c892878a318.tar.gz
SERVER-16469 findAndModify runImpl(): set limit of -1 on query
This allows findAndModify operations that include a sort to take advantage of the top-K sort logic in the query engine. This reduces the memory footprint of the operation from O(N) to O(1), where N is the number of documents matching the query predicate.
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 56410a59916..5467b7f705c 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -223,10 +223,15 @@ namespace mongo {
bool found = false;
{
CanonicalQuery* cq;
+ const BSONObj projection;
+ const long long skip = 0;
+ const long long limit = -1; // 1 document requested; negative indicates hard limit.
uassertStatusOK(CanonicalQuery::canonicalize(ns,
query,
sort,
- BSONObj(), // projection
+ projection,
+ skip,
+ limit,
&cq,
whereCallback));