I am using pymongo to fetch around 2M documents in one query, each document only contains three string fields. the query is just a simple find(), without any limit() or batchSize().
While iterating through the cursor, I noticed that the script waits for about 30~40seconds after processing around 25k documents.
So I am wondering does mongo return all the 2M results in one batch? what is the default batchSize() in pymongo?
The cursor in MongoDB defaults to returning up to 101 documents or enough to get you to 1 MB. Calls to iterate thru the cursor after that pop up to 4MB. The number of documents returned will be a function of how big your documents are:
http://docs.mongodb.org/manual/core/cursors/
You can use the batch_size() method in pymongo on the cursor to override the default - however it won't go above 16 MB (the maximum BSON document size):
http://api.mongodb.org/python/current/api/pymongo/cursor.html