Query
MATCH (u:User {tildaid:$user})
OPTIONAL MATCH (o:Organization {alias:$org})
UNWIND $lists.checks AS c
CALL (u, o, c) { // scope=Study policies=work-order-edit
MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role)
WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_0
WITH DISTINCT u, o, a, c
MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study)
WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds )
MATCH (wo:WorkOrder {tildaid:c.id})
WHERE wo.study_id = st.tildaid
RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient
UNION // scope=Study policies=work-order-edit
MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?})
WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds )
MATCH (wo:WorkOrder {tildaid:c.id})
WHERE wo.study_id = st.tildaid
RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient }
RETURN checkIdx, User, Organization, Study, Site, Patient
Optimizer suggestions
No suggestion for this shape yet — generate one now and it will read this exact statement and its timings.
p95 latency over time
95th-percentile elapsedTimeMs per bucket
p50 latency over time
Median elapsedTimeMs per bucket
Executions / bucket
How often this shape ran
p50/p95 are recovered from the per-bucket latency histogram. A rising p95 with a flat p50 means the tail is getting slower (lock contention, GC, a cold cache) even when the typical case is fine.