I was doing some performance benchmarks for Meteor recently to select an approach how to process large amount of data (450000 records) and found weird thing – Meteor was very slow in querying data.
I had two collections: tests and testResults. Tests collection has 15000 records and test results has 450000 in total, 30 for each test. Each test result has key with testId to reference correct test.
So on server side I was iterating over all tests in test collection and then inside of that loop querying test results collection to get all test results for that test.
The operation was so slow that after waiting 5 minutes I had to kill the process. Doing exactly the same operation in Ruby with Mongoid driver was taking about 29 seconds.
Sample code that I used:
Meteor.startup(function () {
var start = new Date();
var counter = 0;
Tests.find({}).forEach(function(test) {
TestResults.find({testCaseId: test.testCaseId}).forEach(function(testResult) {
counter++;
});
})
var time = new Date() - start;
console.log("Count: "+counter);
console.log("Took: "+time+"ms");
});
Am I doing something wrong or there's a problem with Meteor's mongo driver?
I also tried fetching all records as arrays and then using underscore's where() function to query test results – seems to be similar performance.
Thanks,
Kostya