Skip to content

feat(codeowners): Optimize DB query construction for building CODEOWNERS associations#111693

Merged
shashjar merged 2 commits intomasterfrom
shashjar/optimize-db-queries-codeowners-associations-code-owners-auto-sync
Mar 30, 2026
Merged

feat(codeowners): Optimize DB query construction for building CODEOWNERS associations#111693
shashjar merged 2 commits intomasterfrom
shashjar/optimize-db-queries-codeowners-associations-code-owners-auto-sync

Conversation

@shashjar
Copy link
Copy Markdown
Member

@shashjar shashjar commented Mar 26, 2026

Attempting to fix task timeouts in https://sentry.sentry.io/issues/6731345393?project=1 & https://sentry.sentry.io/issues/6869524816?project=1.

Replaces O(n^2) reduce(or_, [Q(external_name__iexact=...) ...]) query construction with a single Lower() + __in query, and deduplicates names prior to querying. Batches per-user access checks (3 queries per user -> 3 queries total) and per-team access checks (1 query per team -> 1 query total).

Adds tests to verify correct behavior with case-insensitive matching & handling of duplicate users/teams.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 26, 2026
@shashjar shashjar requested a review from a team March 26, 2026 22:59
@shashjar shashjar marked this pull request as ready for review March 26, 2026 22:59
@shashjar shashjar requested a review from a team as a code owner March 26, 2026 22:59
@shashjar shashjar removed the request for review from a team March 26, 2026 22:59
@shashjar shashjar merged commit 3d82914 into master Mar 30, 2026
66 checks passed
@shashjar shashjar deleted the shashjar/optimize-db-queries-codeowners-associations-code-owners-auto-sync branch March 30, 2026 16:55
@github-actions github-actions bot locked and limited conversation to collaborators Apr 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants