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 12:24:27.
› →|
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 81733763 · read · last 7d

Query
MATCH (root:GraphNode{tildaid:$graphId}) 
OPTIONAL MATCH (root)-[:GRAPH_TO_VARIABLE{graphid:root.tildaid}]-(var:VariableV2) 
WITH root, collect(DISTINCT var) as graphVars 
MATCH (root)-[rr:GRAPH_NEXT*?..{graphid:root.tildaid}]->(gnode:GraphNode) 
WHERE size(rr) = ? OR rr[-?].path[?] = root.tildaid 
OPTIONAL MATCH (gnode)-[:GRAPH_NODE_TO_PAGE{graphid:root.tildaid}]->(page:GraphPage) 
OPTIONAL MATCH (gnode)-[:GRAPH_NODE_REF_TO_GRAPH_NODE{graphid:$relPropId}]->(refNode:GraphNode) 
WHERE gnode.objtype = ? 
OPTIONAL MATCH (gnode)-[:GRAPH_NODE_REF_TO_QUESTION{graphid:$relPropId}]->(question:QuestionV2) 
WHERE refNode.objtype = ? 
WITH root, gnode, page, refNode, case when refNode.objtype = ? then question when refNode.objtype = ? then refNode else null end as question, rr, graphVars 
OPTIONAL MATCH (question)-[:QUESTION_TO_QUESTION_SPEC]->(questionSpec:QuestionSpec) 
OPTIONAL MATCH (gnode)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]- (nodeBranchCfg:BranchConfig)-[:BRANCH_TO_BRANCH_CONFIG{graphid:$relPropId}]- (nodeBranch:BranchV2) 
OPTIONAL MATCH (gnode)-[cfgRel:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]- (:BranchConfig)-[:ACTIVATION_RULE_TO_BRANCH_CONFIG{graphid:cfgRel.graphid}]- (:ActivationRule)-[:ACTIVATION_RULE_TO_CHAIN{graphid:cfgRel.graphid}]- (nodeChain:ActivationRuleChain) 
OPTIONAL MATCH (gnode)-[:BRANCH_TO_BRANCH_CONFIG{graphid:root.tildaid, graphid:$relPropId}]->(cfg:BranchConfig) 
WHERE gnode.objtype = ? 
OPTIONAL MATCH (cfg)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]->(cfgRef:GraphNodeRef) 
OPTIONAL MATCH (gnode)-[rel:QUESTION_TO_AUTO_COMPUTE_CFG|QUESTION_TO_CORRECTNESS_CHECK{graphid:$relPropId}]->(acc:AutoComputeConfig) 
OPTIONAL MATCH (acc)-[:AUTO_COMPUTE_TO_BRANCH_CONFIG]->(acBranchCfg:BranchConfig) 
OPTIONAL MATCH (acBranchCfg)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]->(acCfgRef:GraphNodeRef) 
OPTIONAL MATCH (gnode)-[aqRel:QUESTION_TO_AUTO_QUERY{graphid:$relPropId}]->(aqcfg:AutoQueryConfig{enabled:true}) 
WHERE aqRel.sourceprotocolid IS NULL 
OPTIONAL MATCH (aqcfg)-[:AUTO_QUERY_TO_BRANCH_CONFIG]->(aqBranchCfg:BranchConfig) 
WITH gnode, page, refNode, cfg, rr, questionSpec, question, CASE WHEN size(rr) > ? THEN rr[-?].path ELSE [root.tildaid] END as nodePath, CASE WHEN size(rr) > ? THEN rr[-?].flags ELSE ? END as nodeFlags, CASE WHEN size(rr) > ? THEN rr[-?].who ELSE [] END as nodeWho, CASE WHEN type(rel) = ? THEN true ELSE false END as isCorrectnessCheckConfig, collect(DISTINCT cfgRef.tildaid) as cfgRefIds, collect(DISTINCT nodeBranch.tildaid) as branchIds, collect(DISTINCT nodeChain.tildaid) as activationChainIds, acc, acBranchCfg, collect(DISTINCT acCfgRef.tildaid) as autoComputeBranchRefIds, graphVars, collect(DISTINCT CASE WHEN aqcfg IS NOT NULL THEN {aqcfg: aqcfg, aqBranchCfg: aqBranchCfg} END) as autoQueryConfigs 
WITH gnode as node, page, refNode, cfg as branchCfg, cfgRefIds as branchRefIds, questionSpec, question, branchIds, activationChainIds, nodePath as path, gnode.objtype as objType, nodeFlags as flags, nodeWho as who, acc as autoComputeConfig, acBranchCfg as autoComputeBranchCfg, autoComputeBranchRefIds, autoQueryConfigs, isCorrectnessCheckConfig, graphVars 
RETURN {node:node, page:page, refNode:refNode, questionSpec:questionSpec, question:question, branchCfg:branchCfg, branchRefIds:branchRefIds, path:path, objType:objType, flags:flags, who:who, branchIds:branchIds, activationChainIds:activationChainIds, autoComputeConfig:autoComputeConfig, autoComputeBranchCfg:autoComputeBranchCfg, autoComputeBranchRefIds:autoComputeBranchRefIds, autoQueryConfigs:autoQueryConfigs, isCorrectnessCheckConfig:isCorrectnessCheckConfig, graphVars:graphVars}

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

rewrite Replace the fan-out OPTIONAL MATCH chain with per-node COLLECT subqueries
The issueAfter the GRAPH_NEXT variable-length expansion produces one row per gnode, the statement chains about 10 OPTIONAL MATCHes. Five of them only feed list aggregations: nodeBranchCfg→nodeBranch, cfgRel→BranchConfig→ActivationRule→nodeChain, cfg→cfgRef, acBranchCfg→acCfgRef and aqcfg→aqBranchCfg. Each of these multiplies the row count by its own match count, so a gnode with 3 branches, 3 chains, 3 cfgRefs and 2 auto-query configs becomes 54+ rows. Those rows are then folded back by the big `WITH ... collect(DISTINCT ...)`, which also has to group on whole nodes and maps (gnode, page, refNode, cfg, questionSpec, question, acc, acBranchCfg, graphVars, rr). This cartesian blow-up followed by in-memory DISTINCT/grouping is the most likely reason p95 is 900 ms while the average is 182 ms: large graphs explode and small ones don't.
The fixKeep as row-producing OPTIONAL MATCHes only the patterns whose variables are grouping keys in the original: page, refNode, question, questionSpec, cfg, rel/acc and acBranchCfg. Compute branchIds, activationChainIds, cfgRefIds, autoComputeBranchRefIds and autoQueryConfigs with COLLECT { } subqueries (Neo4j 5.6+), which run once per row and never multiply rows. The final aggregation step then becomes a plain projection with no aggregation. The duplicated-key map `{graphid:root.tildaid, graphid:$relPropId}` is kept exactly as in the original, but it should be checked: only one of the two keys takes effect, which is likely a latent bug.
Proposed rewrite — current query in red −, proposed in green +
- MATCH (root:GraphNode{tildaid:$graphId}) OPTIONAL MATCH (root)-[:GRAPH_TO_VARIABLE{graphid:root.tildaid}]-(var:VariableV2) WITH root, collect(DISTINCT var) as graphVars MATCH (root)-[rr:GRAPH_NEXT*?..{graphid:root.tildaid}]->(gnode:GraphNode) WHERE size(rr) = ? OR rr[-?].path[?] = root.tildaid OPTIONAL MATCH (gnode)-[:GRAPH_NODE_TO_PAGE{graphid:root.tildaid}]->(page:GraphPage) OPTIONAL MATCH (gnode)-[:GRAPH_NODE_REF_TO_GRAPH_NODE{graphid:$relPropId}]->(refNode:GraphNode) WHERE gnode.objtype = ? OPTIONAL MATCH (gnode)-[:GRAPH_NODE_REF_TO_QUESTION{graphid:$relPropId}]->(question:QuestionV2) WHERE refNode.objtype = ? WITH root, gnode, page, refNode, case when refNode.objtype = ? then question when refNode.objtype = ? then refNode else null end as question, rr, graphVars OPTIONAL MATCH (question)-[:QUESTION_TO_QUESTION_SPEC]->(questionSpec:QuestionSpec) OPTIONAL MATCH (gnode)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]- (nodeBranchCfg:BranchConfig)-[:BRANCH_TO_BRANCH_CONFIG{graphid:$relPropId}]- (nodeBranch:BranchV2) OPTIONAL MATCH (gnode)-[cfgRel:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]- (:BranchConfig)-[:ACTIVATION_RULE_TO_BRANCH_CONFIG{graphid:cfgRel.graphid}]- (:ActivationRule)-[:ACTIVATION_RULE_TO_CHAIN{graphid:cfgRel.graphid}]- (nodeChain:ActivationRuleChain) OPTIONAL MATCH (gnode)-[:BRANCH_TO_BRANCH_CONFIG{graphid:root.tildaid, graphid:$relPropId}]->(cfg:BranchConfig) WHERE gnode.objtype = ? OPTIONAL MATCH (cfg)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]->(cfgRef:GraphNodeRef) OPTIONAL MATCH (gnode)-[rel:QUESTION_TO_AUTO_COMPUTE_CFG|QUESTION_TO_CORRECTNESS_CHECK{graphid:$relPropId}]->(acc:AutoComputeConfig) OPTIONAL MATCH (acc)-[:AUTO_COMPUTE_TO_BRANCH_CONFIG]->(acBranchCfg:BranchConfig) OPTIONAL MATCH (acBranchCfg)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]->(acCfgRef:GraphNodeRef) OPTIONAL MATCH (gnode)-[aqRel:QUESTION_TO_AUTO_QUERY{graphid:$relPropId}]->(aqcfg:AutoQueryConfig{enabled:true}) WHERE aqRel.sourceprotocolid IS NULL OPTIONAL MATCH (aqcfg)-[:AUTO_QUERY_TO_BRANCH_CONFIG]->(aqBranchCfg:BranchConfig) WITH gnode, page, refNode, cfg, rr, questionSpec, question, CASE WHEN size(rr) > ? THEN rr[-?].path ELSE [root.tildaid] END as nodePath, CASE WHEN size(rr) > ? THEN rr[-?].flags ELSE ? END as nodeFlags, CASE WHEN size(rr) > ? THEN rr[-?].who ELSE [] END as nodeWho, CASE WHEN type(rel) = ? THEN true ELSE false END as isCorrectnessCheckConfig, collect(DISTINCT cfgRef.tildaid) as cfgRefIds, collect(DISTINCT nodeBranch.tildaid) as branchIds, collect(DISTINCT nodeChain.tildaid) as activationChainIds, acc, acBranchCfg, collect(DISTINCT acCfgRef.tildaid) as autoComputeBranchRefIds, graphVars, collect(DISTINCT CASE WHEN aqcfg IS NOT NULL THEN {aqcfg: aqcfg, aqBranchCfg: aqBranchCfg} END) as autoQueryConfigs WITH gnode as node, page, refNode, cfg as branchCfg, cfgRefIds as branchRefIds, questionSpec, question, branchIds, activationChainIds, nodePath as path, gnode.objtype as objType, nodeFlags as flags, nodeWho as who, acc as autoComputeConfig, acBranchCfg as autoComputeBranchCfg, autoComputeBranchRefIds, autoQueryConfigs, isCorrectnessCheckConfig, graphVars RETURN {node:node, page:page, refNode:refNode, questionSpec:questionSpec, question:question, branchCfg:branchCfg, branchRefIds:branchRefIds, path:path, objType:objType, flags:flags, who:who, branchIds:branchIds, activationChainIds:activationChainIds, autoComputeConfig:autoComputeConfig, autoComputeBranchCfg:autoComputeBranchCfg, autoComputeBranchRefIds:autoComputeBranchRefIds, autoQueryConfigs:autoQueryConfigs, isCorrectnessCheckConfig:isCorrectnessCheckConfig, graphVars:graphVars}
+ MATCH (root:GraphNode{tildaid:$graphId})
+ OPTIONAL MATCH (root)-[:GRAPH_TO_VARIABLE{graphid:root.tildaid}]-(var:VariableV2)
+ WITH root, collect(DISTINCT var) as graphVars
+ MATCH (root)-[rr:GRAPH_NEXT*?..{graphid:root.tildaid}]->(gnode:GraphNode)
+ WHERE size(rr) = ? OR rr[-?].path[?] = root.tildaid
+ OPTIONAL MATCH (gnode)-[:GRAPH_NODE_TO_PAGE{graphid:root.tildaid}]->(page:GraphPage)
+ OPTIONAL MATCH (gnode)-[:GRAPH_NODE_REF_TO_GRAPH_NODE{graphid:$relPropId}]->(refNode:GraphNode) WHERE gnode.objtype = ?
+ OPTIONAL MATCH (gnode)-[:GRAPH_NODE_REF_TO_QUESTION{graphid:$relPropId}]->(question:QuestionV2) WHERE refNode.objtype = ?
+ WITH root, gnode, page, refNode, case when refNode.objtype = ? then question when refNode.objtype = ? then refNode else null end as question, rr, graphVars
+ OPTIONAL MATCH (question)-[:QUESTION_TO_QUESTION_SPEC]->(questionSpec:QuestionSpec)
+ OPTIONAL MATCH (gnode)-[:BRANCH_TO_BRANCH_CONFIG{graphid:root.tildaid, graphid:$relPropId}]->(cfg:BranchConfig) WHERE gnode.objtype = ?
+ OPTIONAL MATCH (gnode)-[rel:QUESTION_TO_AUTO_COMPUTE_CFG|QUESTION_TO_CORRECTNESS_CHECK{graphid:$relPropId}]->(acc:AutoComputeConfig)
+ OPTIONAL MATCH (acc)-[:AUTO_COMPUTE_TO_BRANCH_CONFIG]->(acBranchCfg:BranchConfig)
+ WITH root, gnode, page, refNode, question, questionSpec, cfg, rel, acc, acBranchCfg, rr, graphVars,
+ COLLECT { MATCH (cfg)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]->(cfgRef:GraphNodeRef) WHERE cfgRef.tildaid IS NOT NULL RETURN DISTINCT cfgRef.tildaid } as cfgRefIds,
+ COLLECT { MATCH (gnode)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]-(:BranchConfig)-[:BRANCH_TO_BRANCH_CONFIG{graphid:$relPropId}]-(nodeBranch:BranchV2) WHERE nodeBranch.tildaid IS NOT NULL RETURN DISTINCT nodeBranch.tildaid } as branchIds,
+ COLLECT { MATCH (gnode)-[cfgRel:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]-(:BranchConfig)-[:ACTIVATION_RULE_TO_BRANCH_CONFIG{graphid:cfgRel.graphid}]-(:ActivationRule)-[:ACTIVATION_RULE_TO_CHAIN{graphid:cfgRel.graphid}]-(nodeChain:ActivationRuleChain) WHERE nodeChain.tildaid IS NOT NULL RETURN DISTINCT nodeChain.tildaid } as activationChainIds,
+ COLLECT { MATCH (acBranchCfg)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]->(acCfgRef:GraphNodeRef) WHERE acCfgRef.tildaid IS NOT NULL RETURN DISTINCT acCfgRef.tildaid } as autoComputeBranchRefIds,
+ COLLECT { MATCH (gnode)-[aqRel:QUESTION_TO_AUTO_QUERY{graphid:$relPropId}]->(aqcfg:AutoQueryConfig{enabled:true}) WHERE aqRel.sourceprotocolid IS NULL OPTIONAL MATCH (aqcfg)-[:AUTO_QUERY_TO_BRANCH_CONFIG]->(aqBranchCfg:BranchConfig) RETURN DISTINCT {aqcfg: aqcfg, aqBranchCfg: aqBranchCfg} } as autoQueryConfigs
+ WITH gnode as node, page, refNode, cfg as branchCfg, cfgRefIds as branchRefIds, questionSpec, question, branchIds, activationChainIds,
+ CASE WHEN size(rr) > ? THEN rr[-?].path ELSE [root.tildaid] END as path,
+ gnode.objtype as objType,
+ CASE WHEN size(rr) > ? THEN rr[-?].flags ELSE ? END as flags,
+ CASE WHEN size(rr) > ? THEN rr[-?].who ELSE [] END as who,
+ acc as autoComputeConfig, acBranchCfg as autoComputeBranchCfg, autoComputeBranchRefIds, autoQueryConfigs,
+ CASE WHEN type(rel) = ? THEN true ELSE false END as isCorrectnessCheckConfig, graphVars
+ RETURN {node:node, page:page, refNode:refNode, questionSpec:questionSpec, question:question, branchCfg:branchCfg, branchRefIds:branchRefIds, path:path, objType:objType, flags:flags, who:who, branchIds:branchIds, activationChainIds:activationChainIds, autoComputeConfig:autoComputeConfig, autoComputeBranchCfg:autoComputeBranchCfg, autoComputeBranchRefIds:autoComputeBranchRefIds, autoQueryConfigs:autoQueryConfigs, isCorrectnessCheckConfig:isCorrectnessCheckConfig, graphVars:graphVars}
Expected: For large graphs, intermediate row counts and db hits should drop sharply, and so should the in-memory EagerAggregation. The p95 should move toward the ~180 ms average, possibly lower. The absolute weekly gain is small: only 4 runs and 728 ms total in 7 days. Treat this as a fix for tail latency in a user-facing graph load, not a throughput win. · Evidence: Run PROFILE on both versions against the graphId that produced the 900 ms run. Compare the row counts going into the aggregation step (EagerAggregation in the old plan, Projection in the new one), total db hits and memory used. Then diff the result sets for several graphs to confirm they are the same. Pay particular attention to cases where the original's grouping removed duplicate rows (for example, two BRANCH_TO_BRANCH_CONFIG relationships pointing at the same cfg).
index Make sure the root GraphNode lookup on tildaid is backed by a constraint or index
The issueEvery row in this query fans out from `MATCH (root:GraphNode{tildaid:$graphId})`. If GraphNode.tildaid has no supporting index or constraint, this anchor becomes a NodeByLabelScan plus a filter over every GraphNode, and the whole expansion waits on it. It probably already exists because tildaid looks like the entity key, but that is not shown here.
The fixCheck with SHOW CONSTRAINTS / SHOW INDEXES. If tildaid is unique per node (it seems to be the entity id), add a uniqueness constraint. This also gives the planner a NodeUniqueIndexSeek. If an index already exists, skip this suggestion: the anchor is already optimal.
Add this index
CREATE CONSTRAINT graphnode_tildaid_unique IF NOT EXISTS FOR (n:GraphNode) REQUIRE n.tildaid IS UNIQUE
Expected: If the index is missing, the root lookup would go from a label scan (cost grows with the number of GraphNodes) to a single seek, saving anywhere from a few ms to hundreds of ms per call. If it already exists, there is no change. · Evidence: Run EXPLAIN on the statement. The first operator should be NodeUniqueIndexSeek/NodeIndexSeek on GraphNode(tildaid), not NodeByLabelScan followed by Filter. SHOW CONSTRAINTS should list the constraint.

Status: proposed · all suggestions

No rollups for this shape in the window.