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:52.
› →|
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 B903F249 · last 1h

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

rewrite Run the 'is this the earliest version' NOT EXISTS check once per (d, dv), not once per document changelog
The issueIn the second OPTIONAL MATCH, `(d)-[:ALL_CHANGELOG]->(dch:ChangeLog) WHERE d IS NOT NULL AND dch.oldValue CONTAINS ? AND NOT EXISTS { MATCH (d)-[:DOCUMENT_VERSION]->(prev:DocumentVersion) ... }`, the NOT EXISTS subquery only uses d and dv. It never uses dch. Because it sits in the WHERE of the dch match, the planner can run it again for every ChangeLog hanging off the Document. That means walking all of d's DOCUMENT_VERSION relationships and reading versionNumber on each one, per changelog, per DocumentVersion. For documents with many versions and many changelogs, that work grows roughly as versions × changelogs × versions.
The fixWork out the check once, right after collecting vchs, and store it as a boolean `isFirst`. Then the dch OPTIONAL MATCH only needs a cheap check on that boolean plus the CONTAINS filter. If isFirst is false, the planner can skip expanding to the document's changelogs entirely. The results stay the same. Note that the order of the ? placeholders changes: the two coalesce defaults now come before the dch CONTAINS literal, so make sure the parameters are bound in the right order.
Proposed rewrite
MATCH (dv:DocumentVersion) 
WHERE dv.originalFileName IS NULL 
WITH dv 
OPTIONAL MATCH (d:Document)-[:DOCUMENT_VERSION]->(dv) 
CALL { 
WITH dv, d 
OPTIONAL MATCH (dv)-[:ALL_CHANGELOG]->(vch:ChangeLog) 
WHERE vch.oldValue CONTAINS ? 
WITH dv, d, collect(vch) AS vchs 
WITH dv, d, vchs, (d IS NOT NULL AND NOT EXISTS { 
MATCH (d)-[:DOCUMENT_VERSION]->(prev:DocumentVersion) 
WHERE coalesce(prev.versionNumber, ?) < coalesce(dv.versionNumber, ?) }) AS isFirst 
OPTIONAL MATCH (d)-[:ALL_CHANGELOG]->(dch:ChangeLog) 
WHERE isFirst AND dch.oldValue CONTAINS ? 
WITH vchs, collect(dch) AS dchs 
WITH [ch IN (vchs + dchs) 
WHERE ch IS NOT NULL] AS chs 
UNWIND CASE WHEN size(chs) = ? THEN [null] ELSE chs END AS ch 
WITH ch 
ORDER BY ch.createdat ASC, CASE WHEN ch.oldValue CONTAINS ? THEN ? ELSE ? END 
WITH head(collect(ch)) AS clog 
RETURN clog.tildaid AS clogId, clog.oldValue AS oldValue } 
RETURN dv.tildaid, clogId, oldValue
Expected: This could plausibly remove most of the 105 s if documents have many changelogs and many versions. If most documents have one or two changelogs, the gain will be small. Keep in mind the shape ran only once in 7 days (about 105 s total), so the absolute saving is small unless this backfill is run again or on a schedule. · Evidence: Run PROFILE on both versions against the same data. Compare db hits on the Expand(All)/Filter operators under the existential subquery (the DOCUMENT_VERSION expansion to prev), and compare total db hits and elapsed time. Also check that both versions return identical rows (clogId, oldValue for each dv.tildaid).
none No index can serve the `originalFileName IS NULL` anchor
The issueThe query starts with `MATCH (dv:DocumentVersion) WHERE dv.originalFileName IS NULL`. Neo4j 5 range and text indexes only store nodes that have the property, so an IS NULL predicate cannot use an index lookup. This step will always be a NodeByLabelScan on DocumentVersion. The CONTAINS filters on ChangeLog.oldValue are applied after expanding from dv or d, so a TEXT index on oldValue would not be used either.
The fixDon't add an index on DocumentVersion.originalFileName or ChangeLog.oldValue for this query, because the plan won't use it. If this backfill becomes a recurring job, the structural fix is to mark the rows that need it explicitly. Either set a sentinel value (e.g. originalFileName = '' or a boolean needsFileName = true) or add a label such as :MissingFileName, which gives a label scan over just those nodes. For a one-off migration, the label scan is acceptable.
Expected: None from indexing. Only a data-model change (sentinel or label) would shrink the scan, and only if the nodes with a null file name are a small share of all DocumentVersions. · Evidence: In EXPLAIN, the first operator should be NodeByLabelScan(dv:DocumentVersion) followed by a Filter on originalFileName IS NULL. Compare the label count (MATCH (n:DocumentVersion) RETURN count(n)) with the count of nodes where the file name is null to decide whether a marker label is worth it.

Status: proposed · all suggestions

No rollups for this shape in the window.