Reputation: 433
I have a rather simple page with not so much data (about 20k documents in total), and it's VERY sluggish (complete load takes about 30-60 seconds). And what intrigues me most is that data appears gradually on page. Why is that? And why it's so slow?
Here is the page .jade file (it basically returns just order name and order's position name):
table(class="ui celled table")
thead
tr
th Order name
th Position name
tbody
each customerOrders
tr
td {{name}}
td
each customerOrderPositionModified
tr
td
td #{name}
The corresponding .js file is empty.
The router.js file (for Iron Router) is this:
this.route('/buyingList/:supplierUuid', {
data: function() {
var supplierUuid = this.params.supplierUuid;
var retOrd = [];
_.each(orders.find({checked: true}, {name: 1, "customerOrderPosition.name": 1, "customerOrderPosition.quantity": 1, "customerOrderPosition.supplierUuid": 1 }).fetch(), function (order) {
var ret = [];
_.each(order.customerOrderPosition, function (pos) {
var good = Goods.findOne({uuid: pos.goodUuid}, {name:1, supplierUuid:1});
if (good) {
if (good.supplierUuid == supplierUuid){
var company = Companies.findOne({uuid: good.supplierUuid}, {name: 1, uuid: 1});
var tt = {name: good.name, quantity: pos.quantity, companyName: (company ? company.name : "")};
ret.push(tt);
}
}
});
if (ret.length > 0) {
order.customerOrderPositionModified = ret;
retOrd.push(order);
}
});
return { customerOrders: retOrd };
},
name: 'buyingList'
});
The sizes of the collections:
The number of checked orders (which are returned in first query) is about 30.
What am I doing wrong? Or meteor is supposed to be so slow? I doubt it.
Thanks for help in advance.
Upvotes: 0
Views: 255
Reputation: 64312
summary
Meteor can be really slow if more than a few thousand docs are published at a time.
recommendation
Modify your publishers to accept the necessary parameters to publish only the subset of the database that you need to satisfy the UI requirements of the route your are on.
Upvotes: 1