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
Apply LIMIT before CALL subqueries fire in dataset/transgene queries
PR #43 broke THRESHOLD_MEDIUM (3 s) on AlignedDatasets / AllDatasets
and THRESHOLD_SLOW (15 s) on TransgeneExpressionHere because LIMIT
was appended at the end of each Cypher and applied AFTER the four
(or two) CALL subqueries fired for every candidate ds/ep. One of
the dataset subqueries does count(DISTINCT img) across has_source
edges; the transgene one traverses a 5-hop image join inside the
CALL.
Move LIMIT after `WITH DISTINCT ds` (or `WITH DISTINCT ep`) and
before the CALL subqueries so only the rows we keep get enriched.
Drop the ORDER BY from `_dataset_return_clause` and move it next
to LIMIT in each caller, since you can't ORDER BY twice in the
same query.
Dry-run against pdb.v4 (public read-only):
AlignedDatasets LIMIT 10 -> 1.64 s
AllDatasets LIMIT 20 -> 1.10 s
TransgeneExpr... LIMIT 10 -> 0.51 s
All under their respective thresholds.
# LIMIT applied AFTER DISTINCT and BEFORE the CALL subqueries — otherwise
4931
+
# all 86 (AlignedDatasets) / 130 (AllDatasets) datasets get enriched
4932
+
# through 4 CALL subqueries (one of which counts has_source edges) and
4933
+
# the limit only trims afterwards. That blew past the THRESHOLD_MEDIUM
4934
+
# (3 s) perf-test budget on CI.
4935
+
limit_clause=f"LIMIT {limit}"iflimit!=-1else""
4924
4936
main_query=f"""MATCH (ds:DataSet:Individual) WHERE NOT ds:Deprecated AND (:Template:Individual {{short_form:'{template_short_form}'}})<-[:depicts]-(:Template:Individual)-[:in_register_with]-(:Individual)-[:depicts]->(:Individual)-[:has_source]->(ds)
main_query=f"""MATCH (ds:DataSet:Individual) WHERE NOT ds:Deprecated AND (:Template:Individual)<-[:depicts]-(:Template:Individual)-[:in_register_with]-(:Individual)-[:depicts]->(:Individual)-[:has_source]->(ds)
0 commit comments