mongorover icon indicating copy to clipboard operation
mongorover copied to clipboard

batch_size issues

Open rickysland opened this issue 8 years ago • 2 comments

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

rickysland avatar Mar 14 '17 07:03 rickysland

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?

christopherjwang avatar Mar 31 '17 07:03 christopherjwang

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.

rickysland avatar May 16 '17 12:05 rickysland