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:22.
› →|
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 0AA0EDED · write · last 1h

Query
MATCH (o:Organization {tildaid: $org_id})<-[:WORK_ORDER_CONFIG_TO_ORGANIZATION]-(b:WorkOrderConfig) 
WHERE b.delpending = false AND b.study_id = $study_id AND b.study_id IN $lists.accessible_study_ids AND b.status <> ? 
OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CHILD_WORK_ORDER]->(wc:WorkOrder) 
WHERE wc.delpending = false AND wc.status <> ? AND (wc.status IN $lists.child_statuses OR (wc.status = ? AND wc.last_response IS NOT NULL AND coalesce(wc.resolved_at, wc.status_updated_at) IS NOT NULL AND wc.last_response > coalesce(wc.resolved_at, wc.status_updated_at) AND wc.last_response > coalesce(wc.late_reply_ack_at, ?))) 
WITH b, count(wc) AS _match_count 
WHERE _match_count > ? 
OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_STUDY]->(study:Study) 
OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CREATOR]->(creator:User) 
OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_TEMPLATE]->(tmpl:WorkOrderTemplate) 
WITH b, study, creator, tmpl, b.createdat AS _sort_key 
ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC 
LIMIT $fetch_limit 
WITH b, study, creator, tmpl, _sort_key // Resolve WorkPlanInstance id/name for workplan-created configs (wp_object_id 
set). // Mirrors get_workplan_info_for_work_order_config: cfg.wp_object_id -> milestone item // (by tildaid or cfgMilestoneItemId) -> WorkPlanInstance. Non-workplan configs 
yield null. 
OPTIONAL MATCH (wpInstance:WorkPlanInstance)-[:WORKPLAN_INSTANCE_TO_MILESTONE]->(:WorkPlanMilestone) -[:REL_WORKPLAN_INSTANCE_MILESTONE_TO_ITEM]->(wpItem:WorkplanInstanceMilestoneItem) 
WHERE coalesce(b.wp_object_id, ?) <> ? AND (wpItem.tildaid = b.wp_object_id OR wpItem.cfgMilestoneItemId = b.wp_object_id) 
WITH b, study, creator, tmpl, _sort_key, head(collect(wpInstance.tildaid)) AS workplan_id, head(collect(wpInstance.name)) AS workplan_name 
OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CHILD_WORK_ORDER]->(w:WorkOrder) 
WHERE w.delpending = false AND w.status <> ? AND (w.status IN $lists.child_statuses OR (w.status = ? AND w.last_response IS NOT NULL AND coalesce(w.resolved_at, w.status_updated_at) IS NOT NULL AND w.last_response > coalesce(w.resolved_at, w.status_updated_at) AND w.last_response > coalesce(w.late_reply_ack_at, ?))) 
OPTIONAL MATCH (w)-[:WORK_ORDER_TO_STUDY]->(wStudy:Study) 
OPTIONAL MATCH (w)-[:WORK_ORDER_TO_SITE]->(wSite:Site) 
OPTIONAL MATCH (w)-[:WORK_ORDER_TO_CREATOR]->(wCreator:User) 
OPTIONAL MATCH (w)-[:WORK_ORDER_TO_ASSIGNEE]->(wAssignee:User) // Resolve EventScope for Event-type child WOs (null for Standard-type) 
OPTIONAL MATCH (w)-[:WORK_ORDER_TO_EVENT_SCOPE]->(wES:EventScope) // Look up the Site node only for Site-scoped events; guards against null wES and non-Site scopes. // wES.scopeId is a site tildaid (UUID) for Site scopes, country name for Country, ? for Trial. 
OPTIONAL MATCH (wES_Site:Site {tildaid: wES.scopeId}) 
WHERE wES.scopeType = ? 
OPTIONAL MATCH (wPartner:Partner {tildaid: w.recipient_key}) 
OPTIONAL MATCH (:Actor {tildaid: w.recipient_key})-[:FOR_USER]->(wMember:User) 
OPTIONAL MATCH (w)-[:WORK_ORDER_TO_TASK]->(wTask:WorkOrderTask) 
WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, w, wStudy, wSite, wCreator, wAssignee, wES, wES_Site, wPartner, wMember, sum(CASE WHEN wTask.status = ? THEN ? ELSE ? END) AS w_pending_count, sum(CASE WHEN wTask.status = ? THEN ? ELSE ? END) AS w_resolved_count // ENG-?: order children in the DB so children_limit keeps the first N in // DISPLAY order. collect() below preserves incoming row order. // The PARENT keyset terms MUST lead. This 
ORDER BY runs in a 
WITH stage AFTER // the parent 
ORDER BY/
LIMIT, and a later 
ORDER BY re-sorts the whole row stream // — ordering on the child value alone silently re-ranked the CONFIGS by their // child?s QUERY order, not display order: the backward // reversal happens later in Python. 
ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC, (w.createdat IS NULL), w.createdat DESC, w.tildaid 
WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, collect(DISTINCT CASE WHEN w IS NOT NULL THEN { tildaid: w.tildaid, work_order_id: w.work_order_id, title: w.title, work_order_type: w.work_order_type, status: w.status, priority: w.priority, creator_id: w.creator_id, assigned_to_id: w.assigned_to_id, site_id: w.site_id, study_id: w.study_id, document_ids: w.document_ids, contact_list: w.contact_list, cc_list: w.cc_list, goal: w.goal, due_date: w.due_date, last_reachout: w.last_reachout, last_response: w.last_response, resolved_at: w.resolved_at, need_attention_reason: w.need_attention_reason, late_reply: (w.status = ? AND w.last_response IS NOT NULL AND coalesce(w.resolved_at, w.status_updated_at) IS NOT NULL AND w.last_response > coalesce(w.resolved_at, w.status_updated_at) AND w.last_response > coalesce(w.late_reply_ack_at, ?)), accepted_count: w.accepted_count, pending_count: w_pending_count, resolved_count: w_resolved_count, // Mandatory documents this child WO still expects to accept. Pattern // comprehension (like site_number below) keeps the task→subtask // traversal out of the children collect()/count aggregation. Predicate // MUST stay in sync 
with WorkOrderRepository._count_expected_documents. expected_documents_count: size([(w)-[:WORK_ORDER_TO_TASK]->(t2:WorkOrderTask)-[:TASK_HAS_SUBTASK]->(s:WorkOrderSubtask) 
WHERE coalesce(t2.status, ?) <> ? AND coalesce(s.is_optional, false) = false AND coalesce(s.status, ?) <> ? AND (coalesce(s.expects_document, false) = true OR s.expects_document IS NULL OR s.placeholder_id IS NOT NULL OR s.sent_doc_id IS NOT NULL OR s.received_doc_id IS NOT NULL) | s]), createdat: w.createdat, updatedat: w.updatedat, thread_id: w.thread_id, rfc_msgid: w.rfc_msgid, parent_id: w.parent_id, // The child? ?Unknown User? ?Unknown User?site?Site?country?Country?trial?Trial?study?Trial???Organization??partner?Partner??studyteam?Study Team?Site?Site?Country?partner??Partner?studyTeam?? ???? ????Study Team?Non-site?s // `late_reply`: that field is projected only when include_late_reply AND a // child_status filter are both supplied, so reading it here reported False // for every unfiltered list (Codex review, ENG-?). collect(DISTINCT CASE WHEN w IS NOT NULL AND (w.status = ? AND w.last_response IS NOT NULL AND coalesce(w.resolved_at, w.status_updated_at) IS NOT NULL AND w.last_response > coalesce(w.resolved_at, w.status_updated_at) AND w.last_response > coalesce(w.late_reply_ack_at, ?)) THEN true ELSE null END) AS _late_flags // Aggregates are computed over the FULL matching child 
set, BEFORE the // children_limit slice, so a truncated page still renders a correct parent row // (ENG-?). Without these the client can only derive them from `children`, // which is exactly what stops it asking for fewer. 
WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, _late_flags, [child IN _children_raw 
WHERE child IS NOT NULL] AS _children 
WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, _children, size(_children) AS _child_total, reduce(acc = ?, c IN _children | acc + coalesce(c.pending_count, ?)) AS _agg_pending, reduce(acc = ?, c IN _children | acc + coalesce(c.resolved_count, ?)) AS _agg_resolved, size([f IN _late_flags 
WHERE f = true]) > ? AS _has_late_reply, (size(_children) > ? AND all(c IN _children 
WHERE c.status = ?)) AS _all_draft 
RETURN { tildaid: b.tildaid, work_order_config_id: COALESCE(b.work_order_config_id, substring(b.tildaid, ?, ?)), study_id: b.study_id, title: b.title, email_subject: b.email_subject, instructions: b.instructions, email: b.email, recipients: b.recipients, nonsite_recipients: b.nonsite_recipients, site_recipients: b.site_recipients, event_scope_recipients: b.event_scope_recipients, scope_recipients: b.scope_recipients, tasks: b.tasks, // ENG-?: without this, GET /work-order-configs returns plan_steps: [] // for every config and _raw_plan_steps() is dead code. plan_steps: b.plan_steps, plan_instructions: b.plan_instructions, status: b.status, work_order_config_type: b.work_order_config_type, entity_type: b.entity_type, event_id: b.event_id, progress: b.progress, child_count: b.child_count, sent_count: b.sent_count, pending_count: b.pending_count, child_creation_pending: coalesce(b.child_creation_pending, false), // ENG-?: the client recomputes child_creation_pending from these two // (isChildCreationPending), so an unprojected pair reads as ? // and kills the row spinner and the spawn poll. Both, or neither. activated_at: b.activated_at, children_created_at: b.children_created_at, creator_id: b.creator_id, org_id: b.org_id, document_ids: b.document_ids, context_document_ids: COALESCE(b.context_document_ids, []), reasoning: b.reasoning, reasoning_summary: b.reasoning_summary, warning: b.warning, error: b.error, createdat: b.createdat, updatedat: b.updatedat, studyName: CASE WHEN coalesce(b.study_id, ?) = ? THEN ? ELSE COALESCE(study.name, ?) END, creatorName: COALESCE(creator.firstName + ? + creator.lastName, creator.email, ?), // $children_limit < ? is the ? sentinel: a null upper bound makes // the whole slice null in Cypher, so the unlimited case takes the CASE branch. children: CASE WHEN $children_limit < ? THEN _children ELSE _children[?..$children_limit] END, // ENG-? additive aggregates. Always over the full matching child 
set. child_total: _child_total, children_pending_count: _agg_pending, children_resolved_count: _agg_resolved, has_late_reply: _has_late_reply, all_children_draft: _all_draft, template_id: tmpl.tildaid, template_title: tmpl.title, workplan_id: workplan_id, workplan_name: workplan_name } as work_order_config_with_children, _sort_key // Re-assert the parent order AFTER the child aggregation. The child 
ORDER BY // above leads 
with these same terms, but group emission order out of an // aggregation is not guaranteed by Cypher — and the Python loop trims the // lookahead by position, so a re-ordered stream drops the WRONG config and // builds cursors from the wrong boundary. Query order, not display order: // the backward reversal happens later in Python. 
ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC

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

index Index WorkplanInstanceMilestoneItem.cfgMilestoneItemId so the workplan lookup can seek instead of scan
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 node already bound in the pattern. The only anchor is an OR across two properties. Unless both properties are indexed, the planner can't turn the OR into a union of index seeks. It falls back to a label scan of WorkplanInstanceMilestoneItem, or of WorkPlanInstance plus a 2-hop expand, and repeats that scan for every config row that survives `LIMIT $fetch_limit`. This is the most likely reason one call takes over a second.
The fixAdd a lookup index on cfgMilestoneItemId. Also check that WorkplanInstanceMilestoneItem.tildaid has a uniqueness constraint or index (SHOW CONSTRAINTS / SHOW INDEXES), and add one if it doesn't. With both in place, Neo4j 5 can plan the OR as a union of two NodeIndexSeeks per row. It then expands back from wpItem to the milestone and the instance, instead of scanning.
Add this index
CREATE INDEX wp_milestone_item_cfg_item_id IF NOT EXISTS FOR (i:WorkplanInstanceMilestoneItem) ON (i.cfgMilestoneItemId)
Expected: The workplan step should go from scanning every item for each config row to a few index seeks per row. If this step is where most of the time goes, the call could get several-fold faster. This is unverified. · Evidence: PROFILE the query before and after. Before: look for a NodeByLabelScan or AllNodesScan under the OPTIONAL MATCH Apply for wpItem or wpInstance. After: look for NodeIndexSeek and Union operators on WorkplanInstanceMilestoneItem with far fewer db hits.
index Index WorkOrderConfig.study_id so configs can be found without expanding every one in the organization
The issueThe first MATCH, `(o:Organization {tildaid: $org_id})<-[:WORK_ORDER_CONFIG_TO_ORGANIZATION]-(b:WorkOrderConfig) WHERE b.delpending = false AND b.study_id = $study_id ...`, can only start from the Organization. It expands every config the org owns and filters study_id, delpending and status row by row. For a large organization most of those configs belong to other studies and are thrown away.
The fixAdd an index on WorkOrderConfig(study_id). The planner can then seek the configs for `$study_id` and check the single relationship to the org, or use whichever side has fewer rows. delpending and status stay as cheap filters on the result.
Add this index
CREATE INDEX work_order_config_study_id IF NOT EXISTS FOR (b:WorkOrderConfig) ON (b.study_id)
Expected: Fewer rows read in the first stage, roughly in proportion to how many of the org's configs belong to other studies. There is little benefit if most organizations have only one study. · Evidence: Compare the org's total config count with the count for a typical study. After adding the index, PROFILE should show NodeIndexSeek on WorkOrderConfig(study_id), or the planner keeping the org anchor, with lower db hits on the first stage.
index Make sure the tildaid lookups on Actor, Partner and Site, done once per child, are backed by an index
The issueFor every child WorkOrder row, the query runs lookups that are not tied to any already-matched node: `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 has no tildaid index or constraint, each child row triggers a full label scan. The cost grows as configs × children.
The fixRun SHOW CONSTRAINTS and SHOW INDEXES for Actor, Partner and Site on tildaid. Create a uniqueness constraint where tildaid is the key, or a plain index where it isn't. The DDL below is for Actor, the one least likely to already have one. Apply the same pattern to Partner and Site if they turn out to be missing too.
Add this index
CREATE CONSTRAINT actor_tildaid_unique IF NOT EXISTS FOR (a:Actor) REQUIRE a.tildaid IS UNIQUE
Expected: If one of these is unindexed, each child row's cost drops from a full label scan to an index seek. That could be a large share of the 1.1 s. If all three are already constrained, this changes nothing. · Evidence: In PROFILE, NodeByLabelScan on Actor, Partner or Site inside the per-child Apply branches would confirm the problem; after the fix these should be NodeUniqueIndexSeek or NodeIndexSeek. Note: the shape ran only once in 7 days (1.1 s in total), so treat all of these as low priority unless call volume goes up.

Status: proposed · all suggestions

No rollups for this shape in the window.