Mongoose: batchSize() does not work in mongoose

Created on 12 Sep 2016  路  1Comment  路  Source: Automattic/mongoose

It returns all the documents.

According to the mongoDb docs => _modifying the batch size will not affect the user or the application, as the mongo shell and most drivers return results as if MongoDB returned a single batch_

What does this mean? How is it related to mongoose?

help

Most helpful comment

batchSize is meant to be an internal mongodb driver construct that tells the driver how many documents to load at a time, but the driver doesn't pass the batches up to the user. General idea:

  • Model.find()
  • For batch size X, the driver queries mongodb for X documents at a time
  • Once the driver's done, it gives the user all the documents that it loaded back

Generally, batchSize is primarily used for performance tuning if you're using cursors to iterate through huge data sets. You probably just want to use limit most of the time.

>All comments

batchSize is meant to be an internal mongodb driver construct that tells the driver how many documents to load at a time, but the driver doesn't pass the batches up to the user. General idea:

  • Model.find()
  • For batch size X, the driver queries mongodb for X documents at a time
  • Once the driver's done, it gives the user all the documents that it loaded back

Generally, batchSize is primarily used for performance tuning if you're using cursors to iterate through huge data sets. You probably just want to use limit most of the time.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Igorpollo picture Igorpollo  路  3Comments

varunjayaraman picture varunjayaraman  路  3Comments

adamreisnz picture adamreisnz  路  3Comments

gustavomanolo picture gustavomanolo  路  3Comments

tarun1793 picture tarun1793  路  3Comments