node.js - Mongodb query slow response time -


i'm working on project uses flexible schemas. i've setup local mongodb server , using mongoose inside node.

having interesting scaling problem , wondering if these response times normal. if query returns 50 documents, takes 5-10 seconds mongo respond. in same collection, query returns 2 documents milliseconds.

it's not slow connection because it's local, wondering if had idea causing this.

i'm using os x , mongo 3.0.1

edit: documents empty @ moment, 1 or 2 properties.

edit: total number of documents doesn't matter, returned size. if there 51 documents, 50 {_id: "...", _schema:"bar"} , 1 {_id:"...", _schema: "foobar" } collection.find({_schema:"bar"}) takes several seconds , collection.find({_schema:"foobar"}) takes no time.

explain output:

"queryplanner" : {     "plannerversion" : 1,     "namespace" : "mean-dev.documentmodels",     "indexfilterset" : false,     "parsedquery" : {         "$and" : [ ]     },     "winningplan" : {         "stage" : "collscan",         "filter" : {             "$and" : [ ]         },         "direction" : "forward"     },     "rejectedplans" : [ ] }, "serverinfo" : {     "host" : "sams-mbp.local",     "port" : 27017,     "version" : "3.0.1",     "gitversion" : "nogitversion" }, "ok" : 1 

no, should not take time.

the issue in operations in query (projections, sorting, geosearch, grouping, etc). best way solve creating index speed such query.

to create index on _schema field execute command in mongodb:

db.collection.ensureindex({"_schema":1}); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -