Bad example in docs
In the vector search docs (https://docs.convex.dev/search/vector-search#using-a-separate-table-to-store-vectors), there is the following example:
This example uses
await
inside of a for
loop, which I believe is from convex-demos/vector-search
(https://github.com/get-convex/convex-demos/blob/d7e772bf8dcf694a075556c639a0c645b833e4a4/vector-search/convex/movies.ts#L110), and this is, in general a bad practice, and it becomes evident when there's a large number of id
s to enumerate, resulting in very long response times. A better solution would be to use Promise.all
and Array.prototype.filter
as follows:
1 Reply
Ah yep. Promise.all is a bit more efficient since it allows for parallel lookups. I believe these docs were written before we added parallelism 🙂
I'll make a note internally. Thanks for calling it out.