fix: improve _is_user_object_admin query performance#6537
Merged
gagantrivedi merged 1 commit intomainfrom Jan 19, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Contributor
Docker builds report
|
d239ef2 to
b5fe441
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6537 +/- ##
=======================================
Coverage 98.08% 98.08%
=======================================
Files 1293 1293
Lines 46588 46608 +20
=======================================
+ Hits 45696 45716 +20
Misses 892 892 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The original implementation used a single combined query with OR conditions across user, group, and role permissions. This caused Django ORM to generate LEFT OUTER JOINs, resulting in cartesian product explosion and slow queries (~1000ms) on large datasets. Replace with separate queries using early returns: 1. Organisation membership check (security + fast fail) 2. Direct user permission check 3. Group permission check 4. Role permission check (RBAC, if enabled) Each query uses INNER JOINs and returns as soon as permission is found. Follows the same pattern as get_object_id_from_base_permission_filter().
b5fe441 to
8ca1162
Compare
khvn26
approved these changes
Jan 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
The original
_is_user_object_admin()implementation used a single combined query with OR conditions across user, group, and role permissions. This caused Django ORM to generate LEFT OUTER JOINs, resulting in cartesian product explosion and slow queries on large datasets.Replace with separate queries using early returns:
How did you test this code?