My use case is I want to send weekly summary email on monday to every user, I’ve thousands of users and expecting lot more to join.
Is there any perfomance difference between looping through results using cursor like below
const users = Meteor.users.find({});
if (users && users.count() > 0) {
users.forEach((user) => {
console.log(user);
});
}
and this
const users = Meteor.users.find({}).fetch();
if (users && users.length > 0) {
users.forEach((user) => {
console.log(user);
});
}
I think in the first case as we’re not fetching all records, query will be faster but I worry that when we’re looping through cursor, for every loop we’re cursor fetches that single record thus doing too many calls.
Which is the best way for my case? Any help appreciated, thanks.