I have a collection 'matches' with 727000 documents inside. It has 6 fields inside, no arrays just simple integers and object Ids. I am doing query to collection as follows:
matches.find({
$or: [{
homeTeamId: getObjectId(teamId)
}, {
awayTeamId: getObjectId(teamId)
}
],
season: season,
seasonDate: {
'$gt': dayMin,
'$lt': dayMax
}
}).sort({
seasonDate: 1
}).toArray(function (e, res) {
callback(res);
});
Results returning only around 7-8 documents. The query takes about ~100ms, which i think is quite reasonable, but the main problem is, when i call method toArray(), it adds about ~600ms!! I am running server on my laptop, Intel Core I5, 6GB RAM but i can't believe it adds 600ms for 7-8 documents. Tried using mongodb-native driver, now switched to mongoskin, and stil getting the same slow results. Any suggestions ?
callback()do?forEachon thefindresult instead oftoArray? I doubt it will help, but it's an easy thing to try. Also, what'sexplaingive you for that query?