Xray
daily rollups 1h 6h 24h 48h 3d 5d 7d 14d 30d ‹
Last 7 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 17:43:56.
› →|
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 AF34F8C8 · last 7d

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

rewrite Filter choices before the join, and look up Organization by a plain key equality
The issue`WITH DISTINCT q,p,rs.choices AS cList UNWIND cList AS cl WITH DISTINCT q,p,cl AS c` turns every (q, p, rs) row into one row per choice and runs two in-memory DISTINCTs. Only after that does the CONTAINS test run, and it is hidden inside `o.tildaid = CASE WHEN c CONTAINS ? THEN p.orgid END`. Rows that fail the test become `tildaid = null`, which can never match. They still reach the Organization step, and the CASE expression makes it less likely the planner will seek on o.tildaid. The usual fallback is a NodeByLabelScan of Organization for each row. All 3 runs averaged 49 s, and at least one hit the 120 s timeout.
The fixDo the CONTAINS test on the ResponseSet as an `any()` predicate right after the first MATCH. That drops non-matching rs early and removes the UNWIND and both choice-level DISTINCTs. Reduce to DISTINCT (p, q) before touching Organization. Then match Organization with a plain equality `{tildaid: p.orgid}`, which the planner can turn into an index seek. The meaning stays the same: a (p, q) pair qualifies only if some rs on the same gnr has a choice containing the literal. A null `choices` value is still filtered out. The original `RETURN DISTINCT` was redundant next to the aggregation, so it is dropped. The old-style `exists((pattern))` is replaced with an EXISTS {} subquery.
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 p, q
MATCH (o:Organization {tildaid: p.orgid})
RETURN o.alias, collect(DISTINCT p), collect(DISTINCT q)
Expected: Far fewer intermediate rows: rows scale with matching rs instead of with rs × choices. Organization becomes one seek per distinct p instead of a scan per row. This could plausibly take the query from timing out to seconds. That is not guaranteed, because the first expansion from ProtocolVersionV2 is still a label scan. · Evidence: Run PROFILE on the old and new queries with the same literal. Compare total db hits and the row counts going into the Organization operator, check the new plan shows NodeIndexSeek on Organization(tildaid), and confirm both queries return the same alias/p/q sets. Also check how this was logged: a statement that really ran under EXPLAIN would not take 49 s, so the logged text probably doesn't match what actually ran.
index Index Organization.tildaid
The issueThe final `MATCH (o:Organization) WHERE o.tildaid = …` filters on a property that is not shown to have any index. Without one, each driving row causes a full Organization label scan.
The fixCreate a range index on Organization(tildaid). If tildaid is a unique business key, create a uniqueness constraint instead, which also gives you the index. Together with the rewrite above, this makes the Organization step a seek.
Add this index
CREATE INDEX organization_tildaid IF NOT EXISTS FOR (o:Organization) ON (o.tildaid)
Expected: The Organization step should go from a label scan per row to one index seek per row. How much this saves depends on how many Organization nodes there are. · Evidence: Run SHOW INDEXES to confirm no index exists today and that the new one is ONLINE. Then check that the PROFILE plan shows NodeIndexSeek(o:Organization(tildaid)) instead of NodeByLabelScan plus Filter.
rewrite Add relationship types and directions to the undirected expansions
The issue`(p)--(gnr)--(rs)` and `(gnr)--(q)` are untyped and undirected. Every relationship on each GraphNodeRef is expanded both ways, and target labels are only checked afterwards. GraphNodeRef is a hub label linking protocols, response sets and questions, so this fan-out is probably where most of the remaining time goes.
The fixReplace each `--` with the real typed, directed relationship from the data model, for example `(p)-[:HAS_NODE]->(gnr)<-[:FOR_NODE]-(rs)`. You can find the types with `MATCH (:GraphNodeRef)-[r]-(x) RETURN type(r), labels(x), count(*)`. The planner can then use typed expands, which avoids reading unrelated relationships. The exact types can't be filled in here because the shape doesn't show them.
Expected: Fewer relationships traversed per GraphNodeRef. The gain is proportional to how many relationships of other types those nodes have. · Evidence: Check relationship type counts around GraphNodeRef. Then compare db hits on the Expand(All)/Expand(Into) operators in PROFILE before and after adding the types.

Status: proposed · all suggestions

No rollups for this shape in the window.