cursor.toArray() is too slow

22 views
Skip to first unread message

sudarshan kakumanu

unread,
May 9, 2018, 4:20:02 PM5/9/18
to mongo-jackson-mapper

Hi All,

I am using cursor.toArray() to return my collection.find(query) as a list and response time for my API is in 100's of milliseconds. Data fetched into the cursor is very less (a couple of hundred records), the database is indexed on the field I am querying. I have also set the batch size cursor.batchSize(1000).


db.collection.find({"{ "ZIP" : { "$in" : [ "12345"]}}"}.toArray() is my query, and my database is indexed on 'ZIP' . I can see the same query running on the shell within 4 ms.


Mogo driver I am using is: mongojack 2.8.2.


I timed my applications and cursor.toArray()  is where is see the bottle neck. I can provide additional details and sample of application code if needed.

Any insights into getting better performance are appreciated.

Thanks.

Sudharshan.

James Roper

unread,
May 14, 2018, 10:09:36 PM5/14/18
to mongo-jack...@googlegroups.com
Your best bet would be to profile it to see if there are any hotspots in the code, or to see if it is otherwise blocking on the database, eg using YourKit. No one else has reported any performance issues like this, so it's possibly a quirk of your setup.

--
You received this message because you are subscribed to the Google Groups "mongo-jackson-mapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongo-jackson-ma...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages