← docsvc endpoints
GET /api/documents/:id
Neo4j queries this endpoint triggered, grouped by shape (literals → ?),
fetched live from the last 12 traces
(63.7 queries/request — fan-out):
764 executions, 45 distinct shapes,
4.79 s total. live fetch 1485 ms
| Query shape | Count | Avg | Max | Total time ▾ |
|---|---|---|---|---|
WITH ? as total, null as vector MATCH (doc:Document) WHERE doc.tildaid in [?] MATCH (org:Organization{tildaid:?}) OPTIONAL MATCH (study:Study{tildaid:doc.studyId}) CALL { RETURN [] AS policies, [] AS userSiteIds, [] AS userCountryIds, false AS hasReadOnlyRole } CALL { with org, doc WITH org, doc as doc0 match (org)<-[: |
12 | 305 ms | 503 ms | 3.65 s |
MATCH (st:Study {tildaid: $study_id})-[:USES]->(:FolderManager)-[:INCLUDES]->(tmf:Folder {name:?}) WHERE tmf.level = ? MATCH (d:Document {tildaid: $doc_id}) RETURN EXISTS( (tmf)-[:INCLUDES*?..?]->(d) ) AS in_tmf |
204 | <1 ms | 2 ms | 183 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id}) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_ORGANIZATION]->(org:Organization) OPTIONAL MATCH (w)-[r:WORK_ORDER_TO_DOCUMENT]->(doc:Document) OPTIONAL MATCH (doc)<-[:RECOMMENDATION_TO_DOCUMENT]-(rec:Recommendation) WHERE toLower(coalesce(rec.category,?)) = ? AND toLower(coalesce(rec.s |
32 | 4 ms | 7 ms | 136 ms |
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) MATCH (o:Organization{delpending:false, alias:?}) return currentUser as user, o as org, currentUser as tokenUser |
12 | 7 ms | 63 ms | 88 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[r:WORK_ORDER_TO_DOCUMENT]->(d:Document {tildaid: $document_id}) OPTIONAL MATCH (a:WorkOrderActivity)-[:WORK_ORDER_ACTIVITY_TO_DOCUMENT]->(d) WITH d, r, collect(a) AS acts WITH d, r, head([x IN acts WHERE coalesce(x.sender,?) <> ? | x.sender]) AS sender_value OPTIONAL MATCH |
24 | 3 ms | 21 ms | 79 ms |
MATCH (w:WorkOrder {tildaid: $wo}) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_STUDY]->(s:Study) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_SITE]->(site:Site) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_CREATOR]->(creator:User) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_ASSIGNEE]->(assignee:User) OPTIONAL MATCH (resolver:User {tildaid: w.resolved_by}) |
32 | 2 ms | 4 ms | 74 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[r:WORK_ORDER_TO_DOCUMENT]->(d:Document) // Scope activities to THIS work order (via WORK_ORDER_TO_ACTIVITY); a Document node can // be shared across work orders, so matching WORK_ORDER_ACTIVITY_TO_DOCUMENT alone could // surface another work order?Received?RECEIVED?RECEIVE |
2 | 36 ms | 64 ms | 73 ms |
MATCH (w:WorkOrder {tildaid:$wo})-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity {activity_type:?}) WITH a ORDER BY coalesce(a.last_attempt_at, a.createdat) DESC RETURN a.errors AS errors, a.retry_count AS retry_count LIMIT ? |
32 | 2 ms | 67 ms | 70 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity) WHERE a.activity_type = ? AND a.from_ai_teammate_name IS NOT NULL AND a.from_ai_teammate_name <> ? RETURN a.from_ai_teammate_name AS name ORDER BY coalesce(a.createdat, a.timestamp) ASC LIMIT ? |
4 | 14 ms | 54 ms | 54 ms |
MATCH (a:WorkOrder {tildaid: $from_id}) MATCH (b:WorkOrderActivity {tildaid: $to_id}) MERGE (a)-[r:WORK_ORDER_TO_ACTIVITY]->(b) ON CREATE SET r = $properties, r.createdat = timestamp() RETURN r write |
2 | 22 ms | 42 ms | 43 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_TASK]->(t:WorkOrderTask) OPTIONAL MATCH (t)-[:TASK_HAS_SUBTASK]->(sub:WorkOrderSubtask) WITH w, t, sum(CASE WHEN sub IS NOT NULL AND coalesce(sub.status, ?) <> ? THEN ? ELSE ? END) AS subtask_count, sum(CASE WHEN sub.status = ? THEN ? ELSE ? END) AS complete |
4 | 10 ms | 36 ms | 40 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity) WHERE ?=? AND a.activity_type IN $activity_types RETURN count(a) as total |
4 | 8 ms | 29 ms | 31 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id}) WHERE w.delpending = false WITH w, $message_id AS mid, $in_reply_to AS irt, $references AS refs, $provider_thread_id AS pth // Initialize lists if null SET w._message_ids = coalesce(w._message_ids, []) SET w._reference_ids = coalesce(w._reference_ids, []) SET w._provider_th write |
2 | 13 ms | 25 ms | 26 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity) WHERE ?=? RETURN count(a) as total |
2 | 12 ms | 24 ms | 25 ms |
MATCH (w:WorkOrder {tildaid: $wo_id}) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_STUDY]->(s_link:Study) OPTIONAL MATCH (st:Study {tildaid: w.study_id}) WITH w, CASE WHEN s_link IS NOT NULL THEN s_link ELSE st END AS s OPTIONAL MATCH (w)-[:WORK_ORDER_TO_ORGANIZATION]->(org:Organization) RETURN w.tildaid AS work_order_id, coales |
2 | 10 ms | 18 ms | 19 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[r:WORK_ORDER_TO_DOCUMENT]->(d:Document) WHERE ($status IS NULL OR coalesce(r.status, ?) IN $status) AND ($direction IS NULL OR ( coalesce(r.direction, ?) IN $direction AND (coalesce(r.direction, ?) <> ? OR r.sentat IS NOT NULL OR EXISTS { MATCH (sentAct:WorkOrderActivity { |
2 | 8 ms | 15 ms | 16 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[r:WORK_ORDER_TO_DOCUMENT]->(d:Document {tildaid: $doc_id}) RETURN properties(r) AS rel |
12 | 1 ms | 5 ms | 16 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id}) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_ACTIVITY]->(sent:WorkOrderActivity) WHERE sent.activity_type = ? AND sent.status = ? WITH w, max(coalesce(sent.updatedat, sent.createdat)) AS last_sent_ts MATCH (w)-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity) WHERE a.activity_type = ? |
2 | 8 ms | 15 ms | 16 ms |
MATCH (a:WorkOrderActivity {tildaid: $activity_id})-[:WORK_ORDER_ACTIVITY_TO_DOCUMENT]->(d:Document) MATCH (w:WorkOrder {tildaid: $work_order_id})-[r:WORK_ORDER_TO_DOCUMENT]->(d) SET r.sentat = $sentat RETURN d.tildaid as document_id write |
2 | 8 ms | 10 ms | 15 ms |
MATCH(a:Actor{orgId:?,scopeId:?,userId:?,delpending:false}) RETURN a |
12 | 1 ms | 5 ms | 13 ms |
MATCH (n:WorkOrder {tildaid: $node_id}) RETURN n |
68 | <1 ms | 1 ms | 12 ms |
MATCH (a:WorkOrder {tildaid: $from_id}) MATCH (b:Document {tildaid: $to_id}) MERGE (a)-[r:WORK_ORDER_TO_DOCUMENT]->(b) ON CREATE SET r = $properties, r.createdat = timestamp() RETURN r write |
12 | <1 ms | 7 ms | 11 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})<-[:FACT_TO_WORK_ORDER]-(f:Fact) WHERE f.delpending = false RETURN f ORDER BY f.createdat ASC |
54 | <1 ms | 1 ms | 8 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity) WHERE a.timestamp < $current_timestamp AND ( (a.activity_type = ? AND a.status = ?) OR a.activity_type = ? OR a.activity_type = ? ) RETURN a ORDER BY a.timestamp DESC LIMIT ? |
2 | 4 ms | 7 ms | 8 ms |
MATCH (a:WorkOrderActivity {tildaid: $from_id}) MATCH (b:Document {tildaid: $to_id}) MERGE (a)-[r:WORK_ORDER_ACTIVITY_TO_DOCUMENT]->(b) ON CREATE SET r = $properties, r.createdat = timestamp() RETURN r write |
12 | <1 ms | 6 ms | 8 ms |
MATCH (w:WorkOrder {tildaid: $wo})-[:WORK_ORDER_TO_ORGANIZATION]->(org:Organization) RETURN org.alias AS org_alias |
14 | <1 ms | 4 ms | 6 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity) WHERE ?=? AND a.activity_type IN $activity_types AND a.status IN $statuses OPTIONAL MATCH (d:Document) WHERE d.tildaid IN COALESCE(a.docIds, []) WITH w, a, COLLECT(DISTINCT {tildaid: d.tildaid, fileName: d.fileName, contentTy |
24 | <1 ms | 1 ms | 5 ms |
MATCH (n:WorkOrder {tildaid: $node_id}) SET n += $props, n.updatedat = $updatedat RETURN n write |
6 | <1 ms | 1 ms | 5 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_TASK]->(t:WorkOrderTask)-[:TASK_HAS_SUBTASK]->(s:WorkOrderSubtask) WHERE coalesce(t.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.p |
32 | <1 ms | 1 ms | 5 ms |
MATCH (d:Document) WHERE d.tildaid IN $doc_ids RETURN d.tildaid as tildaid, d.fileName as fileName, d.contentType as contentType |
2 | 2 ms | 4 ms | 5 ms |
MATCH (n:WorkOrderActivity {tildaid: $tildaid}) SET n = $properties RETURN n write |
2 | 2 ms | 4 ms | 5 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_TASK]->(t:WorkOrderTask) RETURN t.status AS status, count(t) AS cnt |
32 | <1 ms | 1 ms | 4 ms |
MATCH (o:Organization {tildaid: $org_id}) WHERE o.alias <> ? RETURN o.alias as alias, coalesce(o.aiTeammateName, ?) as aiTeammateName, coalesce(o.aiTeammateEmail, ?) as aiTeammateEmail |
34 | <1 ms | 1 ms | 4 ms |
MATCH (u:User {tildaid: $id}) RETURN coalesce(u.email, ?) AS email |
2 | 2 ms | 4 ms | 4 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_ORGANIZATION]->(org:Organization) RETURN org.alias as org_alias |
2 | 2 ms | 4 ms | 4 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity) WHERE ?=? AND a.activity_type IN $activity_types OPTIONAL MATCH (d:Document) WHERE d.tildaid IN COALESCE(a.docIds, []) WITH w, a, COLLECT(DISTINCT {tildaid: d.tildaid, fileName: d.fileName, contentType: d.contentType}) as doc |
4 | 1 ms | 2 ms | 4 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity) WHERE ?=? OPTIONAL MATCH (d:Document) WHERE d.tildaid IN COALESCE(a.docIds, []) WITH w, a, COLLECT(DISTINCT {tildaid: d.tildaid, fileName: d.fileName, contentType: d.contentType}) as documents // Compute latest AI_MSG draft i |
2 | 2 ms | 2 ms | 4 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id}) RETURN w |
2 | 2 ms | 3 ms | 3 ms |
MATCH (wo:WorkOrder {tildaid: $wo_id}) UNWIND $changelogs AS cl CREATE (c:ChangeLog { tildaid: cl.tildaid, scopeId: $wo_id, category: ?, type: cl.type, changedBy: cl.changed_by, who: cl.who, email: cl.email, oldValue: cl.old_value, newValue: cl.new_value, description: cl.description, operation: cl.operation, reason: ?, write |
2 | 1 ms | 1 ms | 2 ms |
CREATE (n:WorkOrderActivity $properties) RETURN n write |
2 | 1 ms | 1 ms | 2 ms |
MATCH (w:WorkOrder {tildaid: $wo})-[:WORK_ORDER_TO_ORGANIZATION]->(o:Organization) RETURN COALESCE(o.reminderApprovalRequired, true) AS approval_required |
2 | 1 ms | 1 ms | 2 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity) WHERE ?=? AND a.activity_type IN $activity_types AND a.status IN $statuses RETURN count(a) as total |
24 | <1 ms | 1 ms | 1 ms |
MATCH (wo:WorkOrder {tildaid: $wo_id}) OPTIONAL MATCH (wo)-[:WORK_ORDER_TO_ACTIVITY]->(a:WorkOrderActivity {activity_type: ?}) RETURN wo.createdat AS created_at, max(a.timestamp) AS latest_reply_ts |
22 | <1 ms | 1 ms | 1 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_TASK]->(t:WorkOrderTask) RETURN count(t) as total |
4 | <1 ms | 1 ms | 1 ms |
MATCH (w:WorkOrder {tildaid: $work_order_id})-[:WORK_ORDER_TO_ORGANIZATION]->(org:Organization) RETURN org.tildaid as org_id |
2 | <1 ms | 1 ms | 1 ms |
Sorted by total time = the query shape costing this endpoint the most Neo4j time in aggregate (count × avg). A high-count shape with low avg runs many times per request (fan-out / N+1); a low-count shape with high max is an occasional slow query. Executions are counted across the sampled traces above, not the full window — the shapes and per-request fan-out are what matter here.