I would like to optimize my queries with MongoDB, and I was wondering how does the PHP client protocol work with the cursor returning from find() query, does it bring large chunks of the results to the client side or fetches a single record at a time from the remote database and return it to the application?
The PHP driver (and any of the others I have run into) will fetch the results based on the batch size. You can also see this if you run a straight find query in the JS shell, it will say something like "has more" at the end of the first 20 results returned. Calling the iterate (it) function will then load the next batch etc.
In PHP the batch size is configurable, up to the limit on the total returned data size and some other caveats about limits etc. as described here: