perf: fix N+1 query in NamespaceService::groupedForUser #61

Open
Charon wants to merge 0 commits from feat/fix-namespace-n-plus-1 into dev
Member

Summary

  • Replace per-workspace namespace query loop with a single whereIn query on all workspace IDs, then groupBy in PHP
  • Reduces query count from N+2 (1 for workspaces + N for namespaces per workspace) to 3 fixed queries regardless of workspace count
  • Early return when user has no active workspaces to skip the namespace query entirely

Fixes #14

## Summary - Replace per-workspace namespace query loop with a single `whereIn` query on all workspace IDs, then `groupBy` in PHP - Reduces query count from N+2 (1 for workspaces + N for namespaces per workspace) to 3 fixed queries regardless of workspace count - Early return when user has no active workspaces to skip the namespace query entirely Fixes #14
This branch is already included in the target branch. There is nothing to merge.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/fix-namespace-n-plus-1:feat/fix-namespace-n-plus-1
git checkout feat/fix-namespace-n-plus-1

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout dev
git merge --no-ff feat/fix-namespace-n-plus-1
git checkout feat/fix-namespace-n-plus-1
git rebase dev
git checkout dev
git merge --ff-only feat/fix-namespace-n-plus-1
git checkout feat/fix-namespace-n-plus-1
git rebase dev
git checkout dev
git merge --no-ff feat/fix-namespace-n-plus-1
git checkout dev
git merge --squash feat/fix-namespace-n-plus-1
git checkout dev
git merge --ff-only feat/fix-namespace-n-plus-1
git checkout dev
git merge feat/fix-namespace-n-plus-1
git push origin dev
Sign in to join this conversation.
No description provided.