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:02:48.
› →|
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 B131B5A3 · write · last 7d

Query
OPTIONAL MATCH (pv:ProtocolVersionV2 {tildaid: $effectiveVersionId}) 
WITH pv, ? + toString(coalesce(pv.version, ?)) AS versionLabel 
CALL (pv) { 
OPTIONAL MATCH (pv)-[:PROTOCOL_TO_GRAPH_NODE_REF]->(:GraphNodeRef) -[h:QUESTION_TO_AUTO_QUERY {protocolid: $effectiveVersionId}]->(eff:AutoQueryConfig {enabled: true}) 
WHERE h.sourceprotocolid IS NULL 
WITH DISTINCT eff 
ORDER BY eff.tildaid 
RETURN collect(eff) AS effective } 
CALL (pv, effective, versionLabel) { 
MATCH (q:Query {careplanId: $carePlanId})-[:BELONGS_TO]->(aq:AutoQueryConfig) 
WHERE pv IS NOT NULL AND NOT q.state IN $closedQueryStates AND coalesce(q.supersededAt, ?) = ? // A soft-deleted query (its table row was deleted) is no one???????
set status ? 
with reason: ?
set status ? 
with reason: ?{?:?}?{?:?}' 
CREATE (t)-[r2:ALL_CHANGELOG]->(tcl) 
SET r2.tildaid = randomUUID(), r2.createdat = timestamp() 
CREATE (t)-[r1:TAIL_CHANGELOG]->(tcl) 
SET r1.tildaid = randomUUID(), r1.createdat = timestamp() } 
RETURN collect(t) AS closedTasks } 
RETURN count(q) AS superseded, collect(closedTasks) AS closedTaskLists } 
RETURN pv IS NOT NULL AS found, superseded, closedTaskLists

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

index Index Query.careplanId for the supersede subquery's anchor
The issueThe second CALL subquery starts at `MATCH (q:Query {careplanId: $carePlanId})-[:BELONGS_TO]->(aq:AutoQueryConfig)`. careplanId is not the node key, so unless an index exists the planner has to NodeByLabelScan every :Query node and then filter. Nothing else in the subquery narrows the search earlier. The `NOT q.state IN $closedQueryStates` and `coalesce(q.supersededAt, ?) = ?` filters can't be served by an index (negation and a function call), so careplanId is the only predicate that can limit the scan. That label scan is the most likely cause of the 1850 ms p95 against a 410 ms average.
The fixAdd a range index on :Query(careplanId) so the anchor becomes a NodeIndexSeek that returns only one care plan's queries. state and supersededAt are then filtered on that small set. The statement only ran 3 times in 7 days (1.2 s total), so the overall time saved is small. The benefit is mostly a lower tail latency on the write path and less time holding locks while the CREATEs run.
Add this index
CREATE INDEX query_careplanId IF NOT EXISTS FOR (q:Query) ON (q.careplanId)
Expected: If the plan currently shows a NodeByLabelScan on Query, per-call time should drop roughly in proportion to (all :Query nodes) / (queries for this care plan), likely from hundreds of ms to single-digit ms. If an index already exists, expect no change. · Evidence: Run SHOW INDEXES and check for :Query(careplanId). Then PROFILE the statement and compare db hits on the Query operator: it should go from NodeByLabelScan+Filter to NodeIndexSeek. Check p95 again after the deploy. Because there are only 3 calls a week, judge the result from PROFILE db hits more than from p95.
index Make sure ProtocolVersionV2.tildaid is backed by a uniqueness constraint
The issueThe first clause, `OPTIONAL MATCH (pv:ProtocolVersionV2 {tildaid: $effectiveVersionId})`, drives the whole statement. Both subqueries are correlated on pv. If tildaid has no index, every call starts with a label scan of all protocol versions. Without a uniqueness guarantee, the planner also can't assume this returns at most one row, so the CALL subqueries could run once per duplicate.
The fixtildaid looks like an application-generated UUID key, so make it a uniqueness constraint. That gives the lookup an index and guarantees one row (or none) for the rest of the query. If a constraint already exists, this suggestion doesn't apply.
Add this index
CREATE CONSTRAINT protocolversionv2_tildaid IF NOT EXISTS FOR (p:ProtocolVersionV2) REQUIRE p.tildaid IS UNIQUE
Expected: If no index exists today, the pv lookup becomes a constant-time NodeUniqueIndexSeek, saving a scan on every call. If the constraint is already there, expect no change. · Evidence: Run SHOW CONSTRAINTS for ProtocolVersionV2. The PROFILE should show NodeUniqueIndexSeek(pv) as the first operator. Before creating the constraint, check for duplicates with: MATCH (p:ProtocolVersionV2) WITH p.tildaid AS k, count(*) AS c WHERE c > 1 RETURN k, c.
rewrite Stop early when pv is missing instead of filtering inside the write subquery
The issueThe not-found case isn't handled until the second CALL, in `WHERE pv IS NOT NULL` placed after `MATCH (q:Query {careplanId: ...})-[:BELONGS_TO]->(aq)`. So when the version doesn't exist, the engine still expands every Query → AutoQueryConfig pair for the care plan before throwing them all away. The first CALL also does a pointless OPTIONAL MATCH expansion from a null pv.
The fixCheck `pv IS NOT NULL` in its own WITH ... WHERE immediately after the pv lookup, or have the application check for the version first and skip the statement when it's missing. Then neither subquery runs for a missing version. I'm not including a full rewritten statement because the shape as captured is truncated and garbled in the middle (around the soft-delete comment and the changelog CREATE section). Any diff I produced would have to invent clauses. The change is to add `WHERE pv IS NOT NULL` after the line `WITH pv, ... AS versionLabel` and delete it from the inner MATCH. One catch: if found=false must still come back as a row, use a CASE-guarded CALL or a separate existence check in the application, because filtering rows out early would otherwise return zero rows.
Expected: This only changes calls where the version doesn't exist, cutting their cost to a single index seek. Calls where the version is found should be unchanged. With 3 calls a week the gain is small, so do it after the index. · Evidence: Get the full un-normalised statement text from execsvc. PROFILE it with an effectiveVersionId that doesn't exist and check that the Query/BELONGS_TO operators show 0 rows and 0 db hits. Confirm the caller handles found=false (or no row at all) the same way as before.

Status: proposed · all suggestions

No rollups for this shape in the window.