mongorover
mongorover copied to clipboard
batch_size issues
find_one in the old version(26 Aug 2015):
cursor = mongoc_collection_find (collection->c_collection,
MONGOC_QUERY_NONE, 0, 0, -1,
&query, &fields, NULL);
batch_size is -1。
And now it's reuse find function to make find_one:
function MongoCollection:find_one(query, fields, options)
options = options or {}
options.limit = 1
local results = self:find(query, fields, options)
......
I think options.batch_size = -1 is very important in find_one
Hey @rickysland, It looks like using a negative batch size is "analogous to using the limit method". In this case, I feel like it makes more sense to just use limit, as it can easily be reasoned what the limit parameter will do (opposed to a negative batch size).
Am I missing something?
In the old version(26 Aug 2015): batch_size is -1, that mean find_one operation. db server only return 1 result.
But now, although limit is 1, batch_size also is the default value(100?), that mean db server will return batch_size results in find_one operation.