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
{{ message }}
Repository navigation
Pre-resolve functional classification membership on the VA-Spec and NDJSON routes #657
The VA-Spec and NDJSON routes load every variant in each calibration range just to check which range one variant falls in. This issue replaces that with a single up-front query, so those routes stop loading thousands of rows they don't need.
Problem
_classification_contains_variant in lib/annotation/classification.py checks whether a variant falls in a functional classification. It prefers a pre-resolved set of classification ids, which is an O(1) check, and falls back to variant in functional_classification.variants. The fallback loads every variant in the range. Callers that don't pre-resolve pay that cost per classification, and routes eager-load ScoreCalibrationFunctionalClassification.variants to avoid an N+1 (for example routers/score_calibrations.py:749).
The cost lands on the VA-Spec and NDJSON routes: the study-result, functional-statement and pathogenicity-statement routes under /variants/{urn} and /mapped-variants/{urn}, and the score set pathogenicity NDJSON route.
Scope
Pre-resolve containing classification ids for every caller, with one query against score_calibration_functional_classification_variants keyed by the variant ids in the request.
Remove the ORM fallback from _classification_contains_variant, so the id set is required.
Drop the selectinload(...variants) options that exist only for the membership check.
Acceptance criteria
No caller of functional_classification_of_variant or pathogenicity_classification_of_variant loads ScoreCalibrationFunctionalClassification.variants.
A query-count test on the score set pathogenicity NDJSON route asserts a constant number of queries as the variant count grows.
changed the title [-]Optimize Variant Classification Functions to Avoid ORM Relationship Loading[/-][+]Pre-resolve functional classification membership on the VA-Spec and NDJSON routes[/+]on Sep 24, 2026
Activity
[-]Optimize Variant Classification Functions to Avoid ORM Relationship Loading[/-][+]Pre-resolve functional classification membership on the VA-Spec and NDJSON routes[/+]