fix: optimize project queue total count - #9862
Closed
fredheir wants to merge 1 commit into
Closed
Conversation
👷 Deploy request for heartex-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for label-studio-docs-new-theme pending review.Visit the deploys page to approve it
|
✅ Deploy Preview for label-studio-storybook canceled.
|
✅ Deploy Preview for label-studio-playground canceled.
|
robot-ci-heartex
added a commit
that referenced
this pull request
Aug 10, 2026
Closes #9862 GitOrigin-RevId: 04456b61c62deb8ab003bada17137ac3f706c550
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.
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.