Xray
daily rollups 1h 6h 24h 48h 3d 5d 7d 14d 30d ‹
Last 3 days▾
Ends now. Anything up to this cluster's 30-day retention.
Start and end times
Cancel
Interpreted in UTC (change it at the right of this bar). Earliest available: 2026-10-19 23:34:15.
› →|
updated 1d ago
Sample data. This database was generated by scripts/seed_dev_db.py — every service, deploy, person and figure on this page is synthetic. Names are sample.*@seed.invalid and image tags are prefixed SEED-. Nothing here happened.
← query trends

Query shape trend

plan 96097A0D · last 3d

Optimizer suggestions — proposals from claude-opus-5-5, 3d ago; suggests only, a human applies

index Index Organization.tildaid so the final MATCH becomes a seek
The issue`match (o:Organization) where o.tildaid = case when c contains ? then p.orgid end` runs once for every distinct (q, p, c) row coming out of the UNWIND. The equality's right-hand side depends on the row, and no lookup index on Organization.tildaid is listed. Without one, the planner most likely builds a Cartesian product with a NodeByLabelScan on Organization and filters every row. That means rows × organizations comparisons, which fits a p95 of 120 000 ms (the timeout).
The fixCreate a range index on Organization.tildaid. The planner can then use an Apply with NodeIndexSeek(o.tildaid = <row value>) for each row instead of scanning the label. If tildaid is a real business key, a uniqueness constraint (CREATE CONSTRAINT organization_tildaid_unique IF NOT EXISTS FOR (o:Organization) REQUIRE o.tildaid IS UNIQUE) gives the same index and also guarantees one row per key.
Add this index
CREATE INDEX organization_tildaid IF NOT EXISTS FOR (o:Organization) ON (o.tildaid)
Expected: The Organization step should drop from a label scan per row to a single index seek per row. If that is the current bottleneck, total runtime could fall by an order of magnitude or more. The upstream traversal is unaffected. · Evidence: Run EXPLAIN/PROFILE before and after. Before: look for CartesianProduct or NodeByLabelScan(o:Organization) with large db hits. After: a NodeIndexSeek on Organization(tildaid) under an Apply. Also compare p95 over the next executions; it should stop hitting the 120 s timeout.
rewrite Filter choices before the join instead of UNWIND plus CASE-to-null
The issue`with distinct q,p,rs.choices as cList unwind cList as cl with distinct q,p,cl as c` expands every ResponseSet's choices list into one row per choice and de-duplicates it in memory. The CASE expression then only drops rows whose choice lacks ? by turning the key into null, so the Organization lookup is attempted for every choice. The only thing c is used for is checking whether some choice contains ?. Duplicate rows for the same p are also re-joined to Organization, and the old-style `not exists((pattern))` predicate is deprecated in Neo4j 5.
The fixReplace the UNWIND and CASE with an `any()` predicate on rs.choices applied right after the first MATCH. That prunes (p, rs) pairs early and removes the per-choice rows. Then de-duplicate (q, p) once and join Organization directly on p.orgid, which lets the planner use the tildaid index. The results match the original: a null or empty choices list, or a null orgid, produced no rows before and produces none now. RETURN DISTINCT is dropped because grouping by o.alias already makes each row unique. The EXISTS {} subquery is the Neo4j 5 syntax.
Proposed rewrite
MATCH (p:ProtocolVersionV2)--(gnr:GraphNodeRef)--(rs:ResponseSet)
WHERE NOT EXISTS { (p)<-[:EDITED_FROM]-(:ProtocolVersionV2) }
  AND any(c IN rs.choices WHERE c CONTAINS ?)
MATCH (gnr)--(q:QuestionV2)
WITH DISTINCT q, p
MATCH (o:Organization)
WHERE o.tildaid = p.orgid
RETURN o.alias, collect(DISTINCT p.name), collect(DISTINCT q)
Expected: Far fewer intermediate rows: one per (q, p) instead of one per (q, p, choice). The Organization join runs once per qualifying (q, p). Together with the index, the query should complete well under the timeout, though the exact gain depends on the average length of choices. · Evidence: PROFILE both versions on the same data. Compare rows out of the Unwind/Distinct operators against the new Filter, and total db hits. Check that the result sets match (same aliases, names and question collections). Track p95 after the deploy.

Status: proposed · all suggestions

No rollups for this shape in the window.