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

Byter picture Byter · Aug 9, 2012 · Viewed 10.9k times · Source

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

Answer

Parvin Gasimzade picture Parvin Gasimzade · Aug 9, 2012

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.