The wire protocol permits batchSize to be set for getMore's but there is no way to access this on a cursor returned by the 'aggregate' helper.
The net result is that batchSize can be set only for the initial batch in aggregation, after that it is whatever fits in the 4MB getMore payload (or 16MB when 3.4 comes out, SERVER-21797).
The documentation on the 'aggregate' helper method says:
Specify subsequent batch sizes to OP_GET_MORE operations as with other MongoDB cursors.
Except that isn't possible either. Even if it were possible to construct an OP_GET_MORE manually in the shell, it requires knowledge of the cursor ID, which is not accessible when using the aggregate helper.
This ticket is a request to expose a batchSize method on cursors returned by the collection object aggregate helper method.
Note that some drivers at least already implement this in a much more natural way; C#, for example, implements a batchSize option to the aggregate method that applies for both the initial command and subsequent getMores, completely abstracting the silly shenanigans going on at the wire protocol.
- is related to
-
SERVER-21797 Simplify find batching logic
- Closed
- related to
-
PHPC-1109 Support batchSize getMore option for command cursors
- Closed