Skip to content

refactor: better user queries#205

Merged
marius-mather merged 6 commits intomainfrom
refactor/better-user-queries
Mar 31, 2026
Merged

refactor: better user queries#205
marius-mather merged 6 commits intomainfrom
refactor/better-user-queries

Conversation

@marius-mather
Copy link
Copy Markdown
Collaborator

Description

With larger number of users some of our user queries are slow. Do some basic optimization to improve performance (e.g. including platform + group memberships when getting users for the user dashboard)

amandazhuyilan
amandazhuyilan previously approved these changes Mar 16, 2026
Copy link
Copy Markdown
Contributor

@amandazhuyilan amandazhuyilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets ship it

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the admin user listing queries to improve performance on larger datasets, primarily by reducing expensive subquery patterns and pre-loading related membership data needed by the admin dashboard.

Changes:

  • Eager-load platform/group memberships (and their platform/group objects) when querying users for admin endpoints.
  • Replace several IN (subquery) membership filters with correlated EXISTS predicates.
  • Add explicit is_deleted = false predicates to membership subqueries.

Comment thread routers/admin.py Outdated
Comment thread routers/admin.py
@marius-mather marius-mather requested a review from uwwint March 30, 2026 22:51
@uwwint
Copy link
Copy Markdown
Collaborator

uwwint commented Mar 30, 2026

Looks good to me, but please test extensively in dev/qa-ai

@marius-mather marius-mather merged commit 6bfd238 into main Mar 31, 2026
5 checks passed
@marius-mather marius-mather deleted the refactor/better-user-queries branch March 31, 2026 00:08
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.

4 participants