Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batch_size issues #79

Open
rickysland opened this issue Mar 14, 2017 · 2 comments
Open

batch_size issues #79

rickysland opened this issue Mar 14, 2017 · 2 comments

Comments

@rickysland
Copy link

rickysland commented Mar 14, 2017

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

@christopherjwang
Copy link
Collaborator

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?

@rickysland
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants