You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ProjectSerializer.get_queue_total currently combines a negated annotation relation, a positive annotation relation, and distinct().count(). Django compiles that to a duplicate-producing outer join plus an anti-subquery and DISTINCT. This PR expresses the same membership rule directly as unlabeled OR EXISTS(current-user annotation).
Test asserts one count query, EXISTS present, and DISTINCT absent
Live PostgreSQL exact-result parity verified for all three A/B cases
Acceptance criteria
Exact task-membership parity with the existing predicate
One count query
Correlated EXISTS; no outer annotation join or DISTINCT
SQLite and PostgreSQL-compatible ORM query
Rollout and risk
No schema or API contract change is involved. The risk is limited to task-membership equivalence; the regression matrix and live exact-result comparisons cover that boundary. No feature flag is needed.
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
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.
Reason for change
ProjectSerializer.get_queue_totalcurrently combines a negated annotation relation, a positive annotation relation, anddistinct().count(). Django compiles that to a duplicate-producing outer join plus an anti-subquery andDISTINCT. This PR expresses the same membership rule directly asunlabeled OR EXISTS(current-user annotation).Fixes #9861.
Performance evidence
Read-only PostgreSQL A/B tests on three representative project/user pairs preserved exact counts and reduced server execution time:
The PostgreSQL ORM SQL for the candidate uses one correlated
EXISTS, with no outer annotation join orDISTINCT.Testing
projects/tests/test_serializers.py: 17 passed on SQLiteEXISTSpresent, andDISTINCTabsentAcceptance criteria
EXISTS; no outer annotation join orDISTINCTRollout and risk
No schema or API contract change is involved. The risk is limited to task-membership equivalence; the regression matrix and live exact-result comparisons cover that boundary. No feature flag is needed.
This PR is a mirror for #9862