You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two tRPC procedures execute independent database queries sequentially instead of in parallel with Promise.all. Each pair has no data dependency and can run concurrently to reduce latency.
// Currently sequential (two round-trips):const[totalResult]=awaitctx.db.select({count: count()}).from(challenge).where(themeFilter);const[completedResult]=awaitcompletedQuery;// Fix — parallel:const[[totalResult],[completedResult]]=awaitPromise.all([ctx.db.select({count: count()}).from(challenge).where(themeFilter),completedQuery,]);
Impact
Each sequential pair adds one extra database round-trip per request. With Neon serverless, individual query latency is 5–30ms, so parallelizing saves that overhead on every call to these endpoints.
Notes
The codebase already applies this pattern in other procedures — getStatus in onboarding was parallelized in e364ea7. This is a continuation of that work.
Two tRPC procedures execute independent database queries sequentially instead of in parallel with
Promise.all. Each pair has no data dependency and can run concurrently to reduce latency.Affected Locations
1.
challenge.adminStats—server/api/routers/challenge.tslines 256–2892.
userProgress.getCompletionPercentage—server/api/routers/userProgress.tslines 94–113Impact
Each sequential pair adds one extra database round-trip per request. With Neon serverless, individual query latency is 5–30ms, so parallelizing saves that overhead on every call to these endpoints.
Notes
The codebase already applies this pattern in other procedures —
getStatusin onboarding was parallelized in e364ea7. This is a continuation of that work.