[PR #3497] [MERGED] fix: query perf on setting active orgs #30458

Closed
opened 2026-04-17 21:32:41 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3497
Author: @Kinfe123
Created: 7/20/2025
Status: Merged
Merged: 7/21/2025
Merged by: @Bekacru

Base: mainHead: perf/set-active-org


📝 Commits (1)

📊 Changes

2 files changed (+33 additions, -8 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/adapter.ts (+22 -0)
📝 packages/better-auth/src/plugins/organization/routes/crud-org.ts (+11 -8)

📄 Description

Query performance on setting active org. it is currently benchmarked with small number of organization but you can see how it could get hard when it is used on large number of orgs. it is more than half millisecond improvements even if we introduced a new adapter.

before
Screenshot 2025-07-20 at 2 05 48 PM
after
Screenshot 2025-07-20 at 1 51 31 PM


Summary by cubic

Improved performance when setting the active organization by checking user membership with a faster query.

  • Bug Fixes
  • Reduced database load by avoiding full organization lookups during membership checks.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/3497 **Author:** [@Kinfe123](https://github.com/Kinfe123) **Created:** 7/20/2025 **Status:** ✅ Merged **Merged:** 7/21/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `perf/set-active-org` --- ### 📝 Commits (1) - [`99f1519`](https://github.com/better-auth/better-auth/commit/99f1519efce4216349d93144a3e5b98f588ebf9e) perf: active org ### 📊 Changes **2 files changed** (+33 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/adapter.ts` (+22 -0) 📝 `packages/better-auth/src/plugins/organization/routes/crud-org.ts` (+11 -8) </details> ### 📄 Description Query performance on setting active org. it is currently benchmarked with small number of organization but you can see how it could get hard when it is used on large number of orgs. it is more than half millisecond improvements even if we introduced a new adapter. before <img width="377" height="84" alt="Screenshot 2025-07-20 at 2 05 48 PM" src="https://github.com/user-attachments/assets/e80eeb7c-1196-420e-b5b7-02189086f1e3" /> after <img width="393" height="94" alt="Screenshot 2025-07-20 at 1 51 31 PM" src="https://github.com/user-attachments/assets/9ed83ae8-d85f-4760-9c1b-57bd79955e2d" /> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Improved performance when setting the active organization by checking user membership with a faster query. - **Bug Fixes** - Reduced database load by avoiding full organization lookups during membership checks. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 21:32:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#30458