Iam using mongo as an db for my web app. Java code queries the data from mongo. Curntly there is >40000 in mongo . In one of my api it will return all that documents. So i need only 50 documents to show on the web page. I have tried cursor.limit(50) but it only reduces the time taken by while loop. so i think the whole time is taking from this code DBCursor cursor=collection.find(query,field) . Any ways to reduce it..?.
Iam using mongo as an db for my web app. Java code queries the
Share
Take a look at Database Profiler section of the mongodb documentation. It describes ways of finding out how much time the query execution is taking and then in a later section talks about how to optimize the query.