node.js - Mongodb toArray() performance -


i have collection 'matches' 727000 documents inside. has 6 fields inside, no arrays simple integers , object ids. doing query collection 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 around 7-8 documents. query takes ~100ms, think quite reasonable, main problem is, when call method toarray(), adds ~600ms!! running server on laptop, intel core i5, 6gb ram can't believe adds 600ms 7-8 documents. tried using mongodb-native driver, switched mongoskin, , stil getting same slow results. suggestions ?

toarray() method iterate throw cursor element , load them on memory, highly cost operation. maybe can add index improve query performance, and/or avoid toarray iterating throw cursor.

regards, moacy


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -