So I just updated some code on my site thinking that I’d be giving it back a big speed boost by replacing $set array with $pull and $in:
My old code which was the following was way faster. Any ideas why?
var newArrayOfIds = [...]; // working out exactly what this array is can take some time
Teams.update(teamId, {
$set: {
arrayOfIds: newArrayOfIds
}
});
Here’s the new, slower code:
var idsToRemove = [...]; // working out exactly what this array is can take some time
Teams.update(teamId, {
$pull: {
arrayOfIds: { $in: idsToRemove }
}
});
Here’s the Kadira graph. 22:00 is the time of the update. Even the old method was slow, but the new one is super slow, running at around 13 seconds or so each time.