Xray
daily rollups 1h 6h 24h 48h 3d 5d 7d 14d 30d ‹
Last 7 days▾
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 11:44:59.
› →|
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 5F3CD381 · write · last 7d

Query
MATCH (dv:DocumentVersion {tildaid: $id})<-[:DOCUMENT_VERSION]-(d:Document) 
OPTIONAL MATCH (d)-[:DOC_TO_ORG]->(o:Organization) 
OPTIONAL MATCH (d)<-[:INCLUDES]-(b:Binder)-[:BINDER_FOR]->(study:Study) 
OPTIONAL MATCH (d)<-[:INCLUDES]-(b2:Binder)-[:BINDER_FOR]->(site:Site) 
OPTIONAL MATCH (fm:FolderManager{scopeId:d.studyId})-[:HAS]->(dad:DocAttributeDefinition) 
where dad.name = ? or dad.name = ? 
OPTIONAL MATCH (dv)<-[:DOCUMENT_SOURCE_TO_VERSION]-(ds:DocumentSource)-[:HAS_ATTRIBUTE]->(da: DocAttribute{key: dad.code}) 
OPTIONAL MATCH (dv) - [:UPLOADED_BY] - (u: User) 
OPTIONAL MATCH (d)<-[:INCOMING_EMAIL_TO_DOCUMENT]-(ie:IncomingEmail) 
OPTIONAL MATCH (d)<-[:INCLUDES]-(currentFolder:Folder{folderType:?, delpending: FALSE}) 
WHERE currentFolder.scope IN [?, ?] 
OPTIONAL MATCH (d)-[:FILED_UNDER_SUBARTIFACT]->(currentSubArtifact:SubArtifact)<-[:INCLUDES]-(currentFolder) 
OPTIONAL MATCH (d)-[:HAS_STAGING_INFO]->(stagingInfo:DocumentStagingInfo) 
OPTIONAL MATCH (artifact:Folder{tildaid:coalesce(stagingInfo.folderId, currentFolder.tildaid, ?)})<-[:INCLUDES]-(section:Folder)<-[:INCLUDES]-(zone:Folder)<-[:INCLUDES]-(collection:Folder{level:?}) 
OPTIONAL MATCH (artifact)-[:INCLUDES]->(subArtifact:SubArtifact{tildaid:coalesce(stagingInfo.subArtifactId, currentSubArtifact.tildaid, ?)}) // Who last changed the state. The state itself is never read from the changelog: a // message from docsvc carries it, and a message without it takes the version?stateTag?stagingStatus??????DDocument?????.???.?????.???.???.??') end, docDate: da.value, submissionDelayDays: CASE WHEN da.value IS NULL THEN NULL ELSE toString( toInteger(ceil((d.createdat - datetime(da.value).epochMillis)/?)) ) END, collection: d.collection, stateTag: dv.stateTag, needsAttentionReasons: dv.needsAttentionReasons, newStatus: newStatus, changedBy: changedBy, changedByName: changedByName, patientId: d.patientId, fileName: d.fileName, documentMetadata: attributesJson, emailSubject: ie.subject, emailMessageId: ie.message_id } ) 
YIELD node 
RETURN node

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

index Index FolderManager.scopeId for the per-study attribute-definition lookup
The issue`OPTIONAL MATCH (fm:FolderManager{scopeId:d.studyId})-[:HAS]->(dad:DocAttributeDefinition)` looks up FolderManager by a non-key property, using a value that comes from the bound Document row. scopeId is not in the property list for indexes this statement uses. Without a range index, the planner has to scan every FolderManager node and filter on scopeId for each incoming row. That is the only anchor in the statement that isn't a tildaid key, so it is the most likely source of the 950 ms p95.
The fixAdd a range index on FolderManager(scopeId) so the planner can do a NodeIndexSeek and then expand :HAS to only that manager's DocAttributeDefinitions. The dad.name filter is applied after the expansion from fm, so it doesn't need its own index.
Add this index
CREATE INDEX folder_manager_scope_id IF NOT EXISTS FOR (fm:FolderManager) ON (fm.scopeId)
Expected: If the plan currently shows NodeByLabelScan + Filter on FolderManager, it should change to NodeIndexSeek. Per-call latency could drop from hundreds of ms to tens of ms, depending on how many FolderManager nodes there are. Because the statement ran only 2 times in 7 days (781 ms total), the cluster-wide saving is small. The gain is in latency for the request that runs this write. · Evidence: Run PROFILE on the statement with a real $id. Check whether the FolderManager row is a NodeByLabelScan/Filter and how many db hits it has, then confirm it becomes NodeIndexSeek(scopeId) after the index is created. Also compare p95 for shape 5F3CD381 over the next week. Check SHOW INDEXES first to make sure an equivalent index doesn't already exist.
index Make sure the tildaid anchors on SubArtifact and Folder are indexed
The issue`OPTIONAL MATCH (artifact)-[:INCLUDES]->(subArtifact:SubArtifact{tildaid:coalesce(...)})` and `OPTIONAL MATCH (artifact:Folder{tildaid:coalesce(stagingInfo.folderId, currentFolder.tildaid, ?)})<-[:INCLUDES]-(section)...` both look up nodes by tildaid. The value is computed per row. If Folder.tildaid has no index or uniqueness constraint, the artifact match becomes a label scan over all Folders, followed by a 3-hop INCLUDES walk up to the collection folder. That happens for every row produced by the earlier OPTIONAL MATCHes (Binder study/site, currentFolder), which multiply together. SubArtifact.tildaid is less critical because it is reached by expanding from artifact. Still, an index lets the planner pick a seek if it reorders the plan.
The fixRun SHOW CONSTRAINTS / SHOW INDEXES. If Folder.tildaid or SubArtifact.tildaid isn't covered, add uniqueness constraints. Ids like these should be unique, and a constraint also creates the backing index. Create the SubArtifact constraint below, and the matching one for Folder if it's missing (CREATE CONSTRAINT folder_tildaid_unique IF NOT EXISTS FOR (f:Folder) REQUIRE f.tildaid IS UNIQUE).
Add this index
CREATE CONSTRAINT subartifact_tildaid_unique IF NOT EXISTS FOR (s:SubArtifact) REQUIRE s.tildaid IS UNIQUE
Expected: If either lookup is currently a label scan, it should become a NodeUniqueIndexSeek, removing a scan that runs once per intermediate row. If both are already constrained, this changes nothing and can be dropped. · Evidence: Look at the PROFILE rows for the artifact (Folder) and subArtifact anchors: NodeByLabelScan with high db hits versus NodeUniqueIndexSeek. Also check that existing data has no duplicate tildaid values before creating the constraints.

Status: proposed · all suggestions

No rollups for this shape in the window.