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 17:15:42.
› →|
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 98AE3433 · last 1h

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

rewrite Stop re-expanding the INCLUDES*?..? ancestor chain separately for every document
The issueFor every candidate doc1, `OPTIONAL MATCH (doc1)<-[:INCLUDES]-(docFolder:Folder) OPTIONAL MATCH (docFolder)<-[:INCLUDES*?..?]-(ancestorFolder:Folder)` walks the folder tree again, then `collect(DISTINCT docFolder) + collect(DISTINCT ancestorFolder)` builds a folderHierarchy list per document. Documents in the same folder share the same ancestors, so the walk is repeated once per document instead of once per folder. In a count-over-all-documents query like this, that walk is probably most of the 4.3 s. This is a guess and needs PROFILE to confirm.
The fixTurn the check around. First collect the folders the user's policies point at (policies are already gathered once per study in the subquery). Then test each document with one bounded existence check, e.g. `EXISTS { (doc1)<-[:INCLUDES*1..N]-(f:Folder) WHERE f IN policyFolders }` (N = 1 + the current upper bound), or the equivalent with a plain list-membership check. This removes the per-document collect, and the walk can stop at the first matching folder. Folder-less (study-wide) policies keep their existing branch. I have not written out the full statement: the captured text is cut off where comments were normalised (the policy and folder filter and the doc1 MATCH are missing), so any full rewrite built from it would be wrong. Apply the change to the source query in docsvc.
Expected: Fewer db hits on the Expand(Into)/VarLengthExpand rows and less memory used by the per-document collect. The gain could be large if many documents share deep folder chains, and small if folders are shallow. Note that this statement ran only once in 7 days (about 4.3 s in total), so the gain matters for the user waiting on the call, not for cluster load. · Evidence: PROFILE with real parameters. Confirm that the VarLengthExpand on INCLUDES and the EagerAggregation for folderHierarchy have the highest db hits and rows. After the change, compare total db hits and peak memory in the PROFILE output, and confirm the seven counts match the old query for the same user.
index Make sure Study.tildaid is indexed for the UNWIND lookup
The issue`UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId` runs once per allowed study id. If Study.tildaid has no index or constraint, each id costs a full NodeByLabelScan on Study plus a Filter, and the cost grows with (number of allowed studies × number of Study nodes).
The fixIf SHOW INDEXES has no range index or uniqueness constraint on Study.tildaid, create one. A uniqueness constraint is better if tildaid really is unique; the plain index below is the safe choice if you have not checked that. The same check applies to Organization.tildaid and User.tildaid, which are looked up by $scopeOrgId0 and $ctxUserId0. Those are probably already constrained as node keys.
Add this index
CREATE INDEX study_tildaid IF NOT EXISTS FOR (s:Study) ON (s.tildaid)
Expected: If the index is missing, the per-id lookup goes from a label scan to a NodeIndexSeek, which saves time in proportion to how many Study nodes there are. If it already exists, nothing changes. · Evidence: Run SHOW INDEXES WHERE 'Study' IN labelsOrTypes. Run EXPLAIN before and after, and look for NodeIndexSeek on Study(tildaid) instead of NodeByLabelScan + Filter under the UNWIND.
index Index DocumentSigner.userId so the signer checks can start from the signer
The issueThe signer check `EXISTS { (doc1)-[:HAS]-(:DocumentAnnotation)-[:ANNOTATION_SIGNER]-(:DocumentSigner{userId:$signerUserId1}) }` appears in the access filter, and again with $signerUserId2 in the UNION branch. Each time, it walks from every candidate document through all of its annotations and their signers before filtering on userId. Without an index on DocumentSigner.userId, the planner cannot start from the few signer nodes that belong to this user and work back to the documents.
The fixCreate a range index on DocumentSigner.userId. The planner can then seek the user's signers and use the result as a semi-join, or at least has the option to. This matters most when the user signs few documents but the scope holds many documents with many annotations.
Add this index
CREATE INDEX document_signer_user_id IF NOT EXISTS FOR (s:DocumentSigner) ON (s.userId)
Expected: Could noticeably reduce the number of HAS/ANNOTATION_SIGNER expansions per document. If the planner keeps anchoring on doc1, it will have no effect, so treat this as worth trying rather than certain. · Evidence: Run PROFILE before and after creating the index. Check whether a NodeIndexSeek on DocumentSigner(userId) appears and whether db hits drop on the Expand rows under the EXISTS subqueries.

Status: proposed · all suggestions

No rollups for this shape in the window.