-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
-
(copied to CRM)
When we run a query on a sharded cluster, if batch size is not specified, the shards will return the results with the default batch size (16MB). For a sharded cluster with a large number of shards (e.g. 80 shards), this could cause high memory usage on the mongos (16MB * 80 = 1.28G).
Currently we can specify the batch size in term of the number of documents. If the average document size is already known, we can specify the batch size to reduce the memory usage in this case. However, in some cases, specifying the batch size by the number of documents might not be very optimal:
- The document size varies for the collection.
- Projection is being used in the query, so it's hard to predicate how much data will be returned without first querying the document.
It would be nice to allow specifying the batch size in term of the data size. Also it would be nice if the size based batch limit (the default 16MB) could be customized with a `setParameter`.