javamongodbmongodb-javamongo-java

Difference between cursor.count() and cursor.size() in MongoDB


What is the difference between the cursor.count() and cursor.size() methods of MongoDB's DBCursor?


Solution

  • From the Javadoc of the MongoDB Java Driver, it says :

    DBCursor.count(): Counts the number of objects matching the query. This does not take limit/skip into consideration.

    DBCursor.size(): Counts the number of objects matching the query. This does take limit/skip into consideration.