feat: optimization pin logic get rooms#895
Open
MarcusviniciusLsantos wants to merge 5 commits intomainfrom
Open
feat: optimization pin logic get rooms#895MarcusviniciusLsantos wants to merge 5 commits intomainfrom
MarcusviniciusLsantos wants to merge 5 commits intomainfrom
Conversation
kallilsouza
approved these changes
Feb 26, 2026
…eat/optimization-pin-logic-get-rooms
…oom IDs are used for pinned rooms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please check if the PR fulfills these requirements
What
Performance optimization in the listing of pinned rooms. Replaces correlated subqueries (which ran for each room) with a two-query strategy: searches for the IDs of pinned rooms (max 3) in a quick query and uses Case/When with literal values for annotation. It also eliminates the problem of N+1 queries in the serializer by passing the IDs of pinned rooms via context.
Why
Users with 500-600 active rooms were experiencing response times above 40 seconds at the listing endpoint. The root cause was four correlated subqueries (Exists/Subquery) executed for each room in the database (up to 2,400 subquery evaluations) plus 20 additional queries in the serializer (N+1 in get_is_pinned). Since users can have a maximum of three pins, materializing these IDs in advance eliminates all this complexity.
Translated with DeepL.com (free version)