[DRIVERS-205] Specify that a batch size of 1 is translated to 2 Created: 23/Feb/15  Updated: 15/Apr/19  Resolved: 30/Oct/15

Status: Closed
Project: Drivers
Component/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to JAVA-1946 If batch size is set to 1, send nToRe... Closed

 Description   

If the user specifies a batch size of 1, the driver must use a batch size of 2 for the initial query, because the server treats nToReturn of 1 in OP_QUERY the same as -1: it closes the cursor after the first batch.

In PyMongo we override batch size of 1 with 2, not just for OP_QUERY but for OP_GET_MORE too.

Let us specify that drivers use batch size 2 instead of 1 for OP_QUERY only, not for OP_GET_MORE.

Let us also discover the history and intent of the server's quirky OP_QUERY behavior, and investigate whether the "find" command will act the same.



 Comments   
Comment by A. Jesse Jiryu Davis [ 27/May/15 ]

Understood, maybe this isn't worth doing after all.

Comment by Derick Rethans [ 27/May/15 ]

Hmm, I don't know whether I would like to change this for the legacy PHP driver. It's technically a BC break. For PHPC, and HHVM, this would work as it's new.

Comment by A. Jesse Jiryu Davis [ 09/Apr/15 ]

Except, at least for the initial query, we can't set batch size to 1, since the server interprets it as -1 and ends the query.

Comment by Bernie Hackett [ 09/Apr/15 ]

Setting a batch size of one is actually useful for finding corrupt / invalid documents. Since drivers generally decode a batch at a time it's often difficult to figure out which document caused the decoder to raise an error.

Comment by A. Jesse Jiryu Davis [ 03/Mar/15 ]

There will be a weird breaking change in PHP, at least, when it upgrades to the "find" command and a batch size of 1 returns a cursor that can be iterated past the first document. I hope it is very rare, since someone who actually wants one document should say "findOne". Setting a tiny batch size in general ought to be very rare since it's so inefficient.

Comment by J Rassi [ 23/Feb/15 ]

To clarify: a batch size of 1 will indeed be supported in the find and getmore commands. It's not clear yet to me whether or not a batch size of 0 will be supported.

Comment by David Storch [ 23/Feb/15 ]

This will only be relevant for "legacy style" find and getmore. The find command has three fields for the information which used to be collapsed into the ntoreturn field: limit, batchSize, and the boolean field singleBatch.

Comment by A. Jesse Jiryu Davis [ 23/Feb/15 ]

FYI david.storch rassi@10gen.com, relevant to the "find" and "getmore" commands.

Generated at Thu Feb 08 08:20:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.