⚡ perf: optimize validate_rooms_for_group with batched IN queries#12
⚡ perf: optimize validate_rooms_for_group with batched IN queries#12chuanman2707 wants to merge 3 commits into
Conversation
Refactored `validate_rooms_for_group` to use a single `SELECT IN` batch query for statuses and another for testing conflicts, drastically reducing the number of SQL queries and improving throughput. Benchmark indicates up to a 56% improvement over the baseline for 100 rooms. Co-authored-by: chuanman2707 <29907469+chuanman2707@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. |
Refactored `validate_rooms_for_group` to use a single `SELECT IN` batch query for statuses and another for testing conflicts, drastically reducing the number of SQL queries and improving throughput. Benchmark indicates up to a 56% improvement over the baseline for 100 rooms. Fixed clippy warning in groups.rs related to unnecessary `sort_by`. Co-authored-by: chuanman2707 <29907469+chuanman2707@users.noreply.github.com>
|
The |
I have removed all the unrelated |
Isolated the batching query refactor to only modify `group_lifecycle.rs` and the clippy fix in `groups.rs` without any unrelated cargo fmt changes. Refactored `validate_rooms_for_group` to use a single `SELECT IN` batch query for statuses and another for testing conflicts, drastically reducing the number of SQL queries and improving throughput. Benchmark indicates up to a 56% improvement over the baseline for 100 rooms. Co-authored-by: chuanman2707 <29907469+chuanman2707@users.noreply.github.com>
💡 What: Replaced the iterative
SELECTloops for querying individual room status and room calendars with batchedSELECT ... WHERE id IN (...)style queries usingsqlx::QueryBuilder.🎯 Why: The iterative queries created an N+1 performance bottleneck when processing requests with multiple rooms. This optimization ensures that checking for availability scales elegantly regardless of the number of rooms provided in the list.
📊 Measured Improvement: Running the benchmark for
validate_rooms_for_grouphandling 100 rooms yielded a 56% improvement (down from ~57ms baseline to ~25ms).PR created automatically by Jules for task 4116908714933274113 started by @chuanman2707