performance - Collection.find() very slow with other BDD Meteor React -


i'm working on app meteor , react. i'm trying have content of inventories_array external mongodb database, it's extremely slow. wait 7 seconds, have 1 object, wait 5 seconds, 2 other objects, etc...

spaces = new mongo.collection("space"); properties = new mongo.collection("property"); inventories = new mongo.collection("inventory"); if (meteor.isclient) {     meteor.subscribe("property");     meteor.subscribe("space");     meteor.subscribe("inventory");       tracker.autorun(function() {           inventories_array = inventories.find({quantitybooked: 2},{fields: {pricetaxexcl: 1, property: 1, space: 1}}).fetch();     console.log(inventories_array);  }  if (meteor.isserver) {     meteor.publish("property", function () {     return properties.find();   });    meteor.publish("space", function () {     return spaces.find();   });   meteor.publish("inventory", function () {     return inventories.find();   });  } 

the inventory object:

{  ...  "property" : objectid("..."),  "space" : objectid("..."),  "quantitybooked":2,  "pricetaxexcl":...,  ... } 

i launch app mongo_url=mongodb://127.0.0.1:27017/mydb meteor run

any ideas why it's slow?

if @ network tab in inspector you'll see data flowing server client each subscription , you'll able judge both how large , how long takes.

i'd recommend @ first step alter inventory publication follows:

meteor.publish("inventory", function () {   if ( this.userid ){ // return data if have logged-in user     return inventories.find({quantitybooked: 2},{fields: {pricetaxexcl: 1, property: 1, space: 1}});   } else {     this.ready();   } }); 

this way server sending required fields required documents (assuming want docs {quantitybooked: 2}.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -