no need to use promise.all(). and I'd
no need to use promise.all(). and I'd keep your batches between 100-1000
7 Replies
So instead of this:
I should just do:
?
or a
for of
loop?yeah, that works! the reason is the inserts aren't actually doing I/O. they're just queuing up writes that will all be flushed if/when the mutation succeeds
I'd prefer just a simple
for
loop, yeahThanks @Jamie !
It's quite confusing when you get started with Convex, that you are writing code that seems like it would be extremely inefficient, but gets translated into something that runs fast 😅
yeah. I mean, this detail is a little subtle. but if you're querying data (
db.query(...)
), making things concurrent with promise.all does help, b/c that might actually do network I/O if values aren't in the cache
but for writes (insert/update etc) there is no need to do this, since they're not actually async under the coversgood to know! Thanks!
Does this mean insert/update don’t actually need to be awaited in general?
I would still await them to be safe. Otherwise, our protection about un awaited promises might kick in.