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 12:23:23.
› →|
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 442678D3 · last 1h

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

index Index WorkplanInstanceMilestoneItem.cfgMilestoneItemId so the workplan lookup stops scanning every instance
The issueThe clause `OPTIONAL MATCH (wpInstance:WorkPlanInstance)-[:WORKPLAN_INSTANCE_TO_MILESTONE]->(:WorkPlanMilestone)-[:REL_WORKPLAN_INSTANCE_MILESTONE_TO_ITEM]->(wpItem:WorkplanInstanceMilestoneItem) WHERE ... (wpItem.tildaid = b.wp_object_id OR wpItem.cfgMilestoneItemId = b.wp_object_id)` has no bound start node. Unless both sides of the OR can be index-seeked, the planner has to start from a WorkPlanInstance (or WorkplanInstanceMilestoneItem) label scan. It then expands instance→milestone→item and filters, once for every one of the up to $fetch_limit configs. This is probably the largest part of the ~1-1.9 s, and it grows with the size of the workplan graph, not the result size.
The fixAdd a range index on cfgMilestoneItemId. With an index on each OR branch, the Neo4j 5 planner can turn the OR into a Union/Distinct of two NodeIndexSeeks that use the b.wp_object_id argument. It can then walk backwards item→milestone→instance for just the 0–2 matching items, instead of scanning the whole workplan graph. Pair this with the tildaid constraint in the next suggestion. Without both, the OR still falls back to a scan.
Add this index
CREATE INDEX wp_item_cfg_milestone_item_id IF NOT EXISTS FOR (n:WorkplanInstanceMilestoneItem) ON (n.cfgMilestoneItemId)
Expected: If the plan switches to index seeks, the cost of the workplan lookup should go from proportional to all WorkPlanInstance subgraphs to a few db hits per config. I would expect the p95 to drop noticeably, possibly by hundreds of ms, but this depends on how big the workplan graph is. The overall gain is small because it ran only 2 times in 7 days, but each call is user-facing latency. · Evidence: Run PROFILE before and after with a real $org_id. Before, look for NodeByLabelScan on WorkPlanInstance or WorkplanInstanceMilestoneItem under the Apply for this OPTIONAL MATCH. After, look for NodeIndexSeek on WorkplanInstanceMilestoneItem(cfgMilestoneItemId) and (tildaid) under a Union/Distinct, with lower total db hits. Then compare p95 after the deploy.
index Add a uniqueness constraint (or index) on WorkplanInstanceMilestoneItem.tildaid
The issueThe other OR branch, `wpItem.tildaid = b.wp_object_id`, needs its own index. The planner can only replace the OR with index seeks if both properties are indexed. If tildaid on WorkplanInstanceMilestoneItem has no constraint or index, the whole predicate falls back to a label scan plus filter for each config row.
The fixFirst check SHOW CONSTRAINTS / SHOW INDEXES. If tildaid on WorkplanInstanceMilestoneItem is not already covered, create a uniqueness constraint. tildaid looks like the node key across this model, so uniqueness is likely correct and also gives the planner accurate cardinality. If duplicates exist, use a plain range index instead.
Add this index
CREATE CONSTRAINT wp_item_tildaid_unique IF NOT EXISTS FOR (n:WorkplanInstanceMilestoneItem) REQUIRE n.tildaid IS UNIQUE
Expected: Together with the cfgMilestoneItemId index, this should let the OR be planned as two index seeks. On its own it does little for the OR. It may also speed up other per-item lookups by tildaid elsewhere in the service. · Evidence: Run SHOW CONSTRAINTS WHERE 'WorkplanInstanceMilestoneItem' IN labelsOrTypes to see if it is already there. Then PROFILE this statement and confirm NodeUniqueIndexSeek or NodeIndexSeek on tildaid in the workplan branch.
index Make sure Actor.tildaid (and Partner/Site.tildaid) are indexed for the per-child recipient lookups
The issueFor every child WorkOrder row, the statement runs unanchored property lookups: `OPTIONAL MATCH (wPartner:Partner {tildaid: w.recipient_key})`, `OPTIONAL MATCH (:Actor {tildaid: w.recipient_key})-[:FOR_USER]->(wMember:User)` and `OPTIONAL MATCH (wES_Site:Site {tildaid: wES.scopeId})`. If any of these labels lacks an index or constraint on tildaid, each child row causes a full label scan. Actor in particular may not have one, because it is only reached through this indirect recipient_key join.
The fixRun SHOW CONSTRAINTS and add a uniqueness constraint for any of Actor, Partner or Site that lacks one on tildaid. The DDL below is for Actor; use the same pattern for Partner or Site if they are also missing. With the constraint in place, each lookup becomes a NodeUniqueIndexSeek driven by the w.recipient_key / wES.scopeId argument.
Add this index
CREATE CONSTRAINT actor_tildaid_unique IF NOT EXISTS FOR (n:Actor) REQUIRE n.tildaid IS UNIQUE
Expected: If one of these is currently a label scan, the cost changes from children × label size to children × O(1) seeks, which could be a large share of the p95. If all three are already indexed, there is no change, and the remaining cost is in the workplan branch and the repeated child traversal. · Evidence: In a PROFILE, check whether NodeByLabelScan or NodeIndexScan appears for Actor, Partner or Site under the per-child Apply operators. After the change, confirm NodeUniqueIndexSeek and lower db hits.

Status: proposed · all suggestions

No rollups for this shape in the window.