What is the difference between the cursor.count()
and cursor.size()
methods of MongoDB's DBCursor
?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- MongoDB can not create unique sparse index (duplic
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
From the Javadoc of the MongoDB Java Driver, it says :
More than an answer I'd like to point out an issue that our team faced "mixing" this two.
We had something like this:
It turned out that after calling the
cursor.count()
method, the limit was ignored (plase take a look at this other question) , we intended to know how many items were returned by the query so we should have called thecursor.size()
method instead, since calling thecount
one did have an undesired collateral effect.I hope this could be helpful to anyone else since it was not that easy to find the source of the issue we were facing.