Concurrency of useQuery calls
In a component with multiple
useQuery
hooks, do the web requests associated with each hook get executed in parallel? To exemplify, let's say we have a component with three useQuery
hooks where each query takes 50ms to complete. Will the component wait 50ms or 150ms for the data from all three queries?2 Replies
The client will ask for the query results together in a single websocket message.
It's then up to the Convex backend to execute these queries, and you should expect them to be executed in parallel (especially as we further horizontally scale the platform).
Excellent. Furthermore, to my understanding there is no advantage to using
useQueries
over useQuery
in this context, right? The purpose of useQueries
is to allow working with a variable number of queries without violating rules of react hooks, and it has nothing to do with parallel execution of queries.