It is possible to run aggregation queries with the {cursor:{batchSize:0}} option, in order to quickly get back a cursor that can subsequently be iterated. This approach is documented here.
The problem with using this option is that it makes debugging slow queries difficult since the database profiler (set to level 1) and mongod logs only record the 'getmore' ops on the cursor, since the original query is very fast.
I think a couple of enhancements are needed :
- add details of the query to the getmore log entry (which is essential for the above case)
- add the details of the query to db.currentOp()
- add the cursorId to the original query log entry (which makes correlating a query and its associated getmores much easier)
- is related to
-
SERVER-4045 Display queries for getmore ops in db.currentOp() output
- Closed
- related to
-
SERVER-16847 Diagnostic log output for all query clients should include plan summary string
- Closed
-
SERVER-17716 Correlate the parts of distributed ops in db.currentOp() output
- Closed
-
SERVER-17862 Unify stats reporting for log/profiler across CRUD operations
- Closed