Skip to content

feat: optimization pin logic get rooms#895

Open
MarcusviniciusLsantos wants to merge 5 commits intomainfrom
feat/optimization-pin-logic-get-rooms
Open

feat: optimization pin logic get rooms#895
MarcusviniciusLsantos wants to merge 5 commits intomainfrom
feat/optimization-pin-logic-get-rooms

Conversation

@MarcusviniciusLsantos
Copy link
Copy Markdown
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added / updated (for bug fixes / features)
  • Do we need to implement analytics?

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)

@MarcusviniciusLsantos MarcusviniciusLsantos changed the title Feat: optimization pin logic get rooms feat: optimization pin logic get rooms Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants