⚡ Bolt: batch pool controller local keys fetch - #63
Conversation
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Implemented
getAllLocalKeysto batch fetch local keys instead of issuing a separate query for each account insidePoolController.getPoolData's map loop. Grouped results in a map for O(1) loop resolution.🎯 Why: Resolves an N+1 database query problem on the high-frequency /api/pool endpoint which scales linearly and reduces database connection saturation as users add more accounts.
📊 Impact: Reduces the number of database queries executed per pool data refresh from O(N+1) to O(2), significantly reducing database load, latency and Node event loop stalls for users with large account pools.
🔬 Measurement: Verifiable by monitoring database load during repeated polling to
/api/pooland noting the reduction in individualfindManyqueries for local keys.Tested successfully utilizing
npm test,npm run lint, andnpm run gate. Thetest:ensure-session-backfilltest throws an expected environmental error linked tonode:testmocking on Node 22 as logged in the existing memory, while remaining integration scripts pass cleanly. Recorded the learning about parallel N+1 queries in.jules/bolt.md.PR created automatically by Jules for task 7955037962684721079 started by @zaydiscold