Xray
1h 6h 24h 48h 3d 5d 7d 14d 30d ‹
Last 1 hour▾
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 22:51:12.
› →|
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 0BFC7296 · last 1h

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

index Composite index for the DslPlanDefinition anchor lookup
The issue`MATCH (pd:DslPlanDefinition{studyId:$studyId, scopeId:$siteId})` filters on two properties that are not a node key. If neither is indexed, the planner has to scan every DslPlanDefinition node and filter it (NodeByLabelScan + Filter). That is a likely cause of the 440 ms p95 against a 53 ms average. Because this anchor comes first, every later expansion depends on it.
The fixAdd a composite range index on (studyId, scopeId) so the anchor becomes a NodeIndexSeek. Check SHOW INDEXES first, since an index may already exist. If each study/site pair can have only one plan definition, use a composite uniqueness constraint instead (CREATE CONSTRAINT ... REQUIRE (pd.studyId, pd.scopeId) IS UNIQUE). It creates the backing index and also protects the MERGE's semantics.
Add this index
CREATE INDEX dsl_plan_definition_study_scope IF NOT EXISTS FOR (pd:DslPlanDefinition) ON (pd.studyId, pd.scopeId)
Expected: If the plan currently shows a label scan, the anchor cost should drop from O(#DslPlanDefinition) to a few db hits, probably taking the tail into single-digit ms. The volume is only 4 calls per week, so the total time saved is small. The main gain is a lower tail latency and shorter write-lock hold time. · Evidence: Run EXPLAIN/PROFILE before the change and look for NodeByLabelScan(pd:DslPlanDefinition) + Filter. After the change, look for NodeIndexSeek on DslPlanDefinition(studyId, scopeId). Also compare p95 for shape 0BFC7296 over the next window.
index Uniqueness constraint on WorkflowV2.tildaid
The issue`MATCH (w:WorkflowV2{tildaid:$workflowId})` looks up by an external ID. Without an index or constraint on tildaid, it scans all WorkflowV2 nodes, and that label probably grows with every workflow version. The planner might even choose to start from Trigger or pd and filter w later.
The fixtildaid looks like a unique external identifier, so declare it with a uniqueness constraint. This creates the backing index, gives the planner a cardinality-1 estimate (a stable plan), and prevents duplicates that would make MERGE create several adopted edges. If duplicates are legitimate, use a plain CREATE INDEX ... ON (w.tildaid) instead.
Add this index
CREATE CONSTRAINT workflowv2_tildaid_unique IF NOT EXISTS FOR (w:WorkflowV2) REQUIRE w.tildaid IS UNIQUE
Expected: w should resolve with a NodeUniqueIndexSeek, which removes a possible full-label scan. The improvement is probably largest on the slow tail executions. · Evidence: Run SHOW CONSTRAINTS/SHOW INDEXES to see whether one already exists. Check that MATCH (w:WorkflowV2) WITH w.tildaid AS id, count(*) AS c WHERE c > 1 RETURN count(*) returns 0 before creating the constraint. Afterwards, PROFILE should show NodeUniqueIndexSeek(w).
rewrite Remove the self-referential Trigger filter and stop deleting the edge MERGE just matched
The issueThe OPTIONAL MATCH reuses the already-bound `t` as `(t:Trigger{scope: t.scope, operation: t.operation})`. That filter always passes (t compared with itself), so it only costs extra property reads. There is also a bigger problem: when pd has already adopted w, the OPTIONAL MATCH binds oldWorkflow = w and r = that same edge. MERGE then matches that edge, and `delete r` removes it, so a re-adopt call silently drops the adoption. If w has several triggers, every row also re-runs MERGE/DELETE.
The fixWrite the old-workflow pattern against plain `(t)`, which gives identical matching without the redundant property predicate. Add `WHERE oldWorkflow <> w` so the existing adoption edge for w is never deleted. Note that this is a behaviour change: it fixes the self-delete case. Separately, check with the service owner whether the intent was to find an old workflow on a *different* trigger with the same scope and operation. If so, bind a new variable, e.g. (t2:Trigger) WHERE t2.scope = t.scope AND t2.operation = t.operation, and the query needs that version instead.
Proposed rewrite
MATCH (pd:DslPlanDefinition{studyId:$studyId, scopeId:$siteId}) 
MATCH (w:WorkflowV2{tildaid:$workflowId})-[:TRIGGER_TO_WORKFLOW]-(t:Trigger) 
OPTIONAL MATCH (pd)-[r:PLAN_DEFINITION_TO_ADOPTED_WORKFLOWS]->(oldWorkflow:WorkflowV2)-[:TRIGGER_TO_WORKFLOW]-(t) 
WHERE oldWorkflow <> w 
MERGE (pd)-[:PLAN_DEFINITION_TO_ADOPTED_WORKFLOWS]->(w) 
DELETE r 
RETURN oldWorkflow.tildaid AS oldWorkflowId, t.operation
Expected: Expect a small per-call saving (fewer property reads and Filter rows). The main effect is correctness: re-adopting the current workflow leaves the edge in place instead of deleting it. · Evidence: In a test DB, call the statement twice with the same $workflowId and check whether the PLAN_DEFINITION_TO_ADOPTED_WORKFLOWS edge from pd to w still exists afterwards. With the original query it should be gone; with the rewrite it should remain. Also compare PROFILE db hits on the OPTIONAL MATCH branch.

Status: proposed · all suggestions

No rollups for this shape in the window.