Skip to content

enh(performance): query memberships breadth first to reduce query count - #3072

Merged
grnd-alt merged 1 commit into
masterfrom
enh/reduce-query-count-for-membership-generation
Oct 22, 2026
Merged

grnd-alt merged 1 commit into
masterfrom
enh/reduce-query-count-for-membership-generation

Conversation

@grnd-alt

@grnd-alt grnd-alt commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

The generateMembership function was depth first before, which caused the db query count to rise with the amount of circles a user was part in. Now it is breadth first and get's all circles of a level in one query. This makes performance dependent on deepness of the membership path instead of the amount of memberships.

Performance test done

I tested on a local instance with a user who has 515 direct memberships
before change: 590 queries produced for the create Circle request
after change: 57 queries produced for the same request

waiting time before: ~2.2 seconds
waiting time after: ~800ms

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Comment thread lib/Db/MemberRequest.php Outdated
Signed-off-by: grnd-alt <git@belakkaf.net>
Assisted-by: ClaudeCode:claude-sonnet-5-5
@grnd-alt
grnd-alt force-pushed the enh/reduce-query-count-for-membership-generation branch from b49cfca to 4b273f5 Compare October 22, 2026 09:06
@grnd-alt

Copy link
Copy Markdown
Member Author

/backport to stable34

@grnd-alt

Copy link
Copy Markdown
Member Author

/backport to stable35

@grnd-alt grnd-alt self-assigned this Oct 22, 2026
@blizzz
blizzz requested a review from cristianscheid October 22, 2026 09:32
@blizzz blizzz added this to the Nextcloud 36 milestone Oct 22, 2026
@grnd-alt
grnd-alt merged commit f477428 into master Oct 22, 2026
50 checks passed
@grnd-alt
grnd-alt deleted the enh/reduce-query-count-for-membership-generation branch October 22, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review enhancement performance php Pull requests that update php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants