Skip to content

perf(organizations): eliminate N+1 queries in listMembers and adminDelete#28777

Draft
diogeneszilli wants to merge 2 commits intocalcom:mainfrom
diogeneszilli:perf/orgs-eliminate-n-plus-1-queries
Draft

perf(organizations): eliminate N+1 queries in listMembers and adminDelete#28777
diogeneszilli wants to merge 2 commits intocalcom:mainfrom
diogeneszilli:perf/orgs-eliminate-n-plus-1-queries

Conversation

@diogeneszilli
Copy link
Copy Markdown

Summary

  • listMembers: Replace per-member enrichUserWithItsProfile() and attributeToUser.findMany() calls with batch operations, reducing from 2N queries to 2 queries
  • adminDelete: Replace N individual prisma.user.update() calls with a single batch $executeRaw UPDATE, and convert include to select to fetch only needed fields (id, username, name, slug)

Test plan

  • Verify listMembers returns the same response shape with batched enrichment
  • Verify adminDelete correctly renames all users in one batch UPDATE
  • Verify attribute expansion still works when expand includes "attributes"
  • Run yarn type-check:ci --force to confirm no type regressions

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants