You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/clauses/match.adoc
+19-3Lines changed: 19 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -639,10 +639,26 @@ RETURN relationshipType, count(r) AS relationshipCount
639
639
[[dynamic-match-caveats]]
640
640
=== Performance caveats
641
641
642
-
`MATCH` queries using dynamic values may not be as performant as those using static values.
643
-
This is because the xref:planning-and-tuning/execution-plans.adoc[Cypher planner] uses statically available information when planning queries to determine whether to use an xref:indexes/search-performance-indexes/index.adoc[index] or not, and this is not possible when using dynamic values.
642
+
`MATCH` queries that use dynamic values may not perform as well as those with static values.
643
+
Neo4j is actively working to improve the performance of these queries.
644
+
The table below outlines performance caveats for specific Neo4j versions.
644
645
645
-
As a result, `MATCH` queries using dynamic values cannot leverage xref:planning-and-tuning/operators/operators-detail.adoc#leaf-operators[index scans or seeks] and must instead use the xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-all-nodes-scan[`AllNodesScan`] operator, which reads all nodes from the node store and is therefore more costly.
646
+
.Neo4j versions and performance caveats
647
+
[%header,cols="a,5a"]
648
+
|===
649
+
| Neo4j versions | Performance caveat
650
+
651
+
| 5.26 -- 2025.07
652
+
| The xref:planning-and-tuning/execution-plans.adoc[Cypher planner] is not able to leverage xref:indexes/search-performance-indexes/index.adoc[indexes] with xref:planning-and-tuning/operators/operators-detail.adoc#leaf-operators[index scans or seeks] and must instead utilize the xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-all-nodes-scan[`AllNodesScan`] operator, which reads all nodes from the node store and is therefore more costly.
653
+
654
+
| 2025.08 -- current
655
+
| The Cypher planner is able to leverage xref:indexes/search-performance-indexes/using-indexes.adoc#token-lookup-indexes[token lookup indexes] when matching node labels and relationship types dynamically.
656
+
This is enabled by the introduction of three new query plan operators:
657
+
xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-dynamic-label-node-lookup[`DynamicLabelNodeLookup`], xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-dynamic-directed-relationship-type-lookup[`DynamicDirectedRelationshipTypeLookup`], and xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-dynamic-undirected-relationship-type-lookup[`DynamicUndirectedRelationshipTypeLookup`].
658
+
It is not, however, able to use indexes on property values.
659
+
For example, `MATCH (n:$(Label) {foo: bar})` will not use any indexes on `n.foo` but can use a `DynamicLabelNodeLookup` on `$(label)`.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/clauses/merge.adoc
+15-34Lines changed: 15 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -741,42 +741,23 @@ RETURN greta.name AS name, labels(greta) AS labels, type(rel) AS relType, collec
741
741
[[dynamic-merge-caveats]]
742
742
=== Performance caveats
743
743
744
-
`MERGE` queries that use dynamic values may not be as performant as those using static values.
745
-
This is because the xref:planning-and-tuning/execution-plans.adoc[Cypher planner] uses statically available information when planning queries to determine whether to use an xref:indexes/search-performance-indexes/index.adoc[index] or not, and this is not possible when using dynamic values.
744
+
`MERGE` queries that use dynamic values may not perform as well as those with static values.
745
+
Neo4j is actively working to improve the performance of these queries.
746
+
The table below outlines performance caveats for specific Neo4j versions.
746
747
747
-
As a result, `MERGE` queries with dynamic values cannot leverage xref:planning-and-tuning/operators/operators-detail.adoc#leaf-operators[index scans or seeks] and must instead use the xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-all-nodes-scan[`AllNodesScan`] operator, which reads all nodes from the node store and is therefore more costly.
748
-
749
-
To circumvent possible performance issues, place the dynamic labels or relationship types within `ON CREATE` or `ON MATCH` subclauses.
750
-
751
-
.Parameters
752
-
[source, parameters]
753
-
----
754
-
{
755
-
"onMatchLabels": ["Filmmaker", "AwardRecipient"],
756
-
"onCreateLabels": ["ScreenWriter", "AwardWinner"]
757
-
}
758
-
----
759
-
760
-
.Merge nodes using dynamic values in `ON CREATE` and `ON MATCH` subclauses
761
-
[source, cypher]
762
-
----
763
-
MERGE (n:Person {name: "Greta Gerwig"})
764
-
ON MATCH
765
-
SET n:$($onMatchLabels)
766
-
ON CREATE
767
-
SET n:$($onCreateLabels)
768
-
RETURN labels(n) AS gretaLabels
769
-
----
770
-
771
-
Because a `Person` node with the `name` "Greta Gerwig" already exists, this query will only `SET` the dynamic labels added to the `ON MATCH` subclause.
| The xref:planning-and-tuning/execution-plans.adoc[Cypher planner] is not able to leverage xref:indexes/search-performance-indexes/index.adoc[indexes] with xref:planning-and-tuning/operators/operators-detail.adoc#leaf-operators[index scans or seeks] and must instead utilize the xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-all-nodes-scan[`AllNodesScan`] operator, which reads all nodes from the node store and is therefore more costly.
779
755
780
-
1+d|Rows: 1
781
-
|===
756
+
| 2025.08 -- current
757
+
| The Cypher planner is able to leverage xref:indexes/search-performance-indexes/using-indexes.adoc#token-lookup-indexes[token lookup indexes] when matching node labels and relationship types dynamically.
758
+
This is enabled by the introduction of three new query plan operators:
759
+
xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-dynamic-label-node-lookup[`DynamicLabelNodeLookup`], xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-dynamic-directed-relationship-type-lookup[`DynamicDirectedRelationshipTypeLookup`], and xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-dynamic-undirected-relationship-type-lookup[`DynamicUndirectedRelationshipTypeLookup`].
760
+
It is not, however, able to use indexes on property values.
761
+
For example, `MERGE (n:$(Label) {foo: bar})` will not use any indexes on `n.foo` but can use a `DynamicLabelNodeLookup` on `$(label)`.
| Cypher can now leverage xref:indexes/search-performance-indexes/using-indexes.adoc#token-lookup-indexes[token lookup indexes] when planning queries with xref:clauses/match.adoc#dynamic-match[dynamic labels and relationship types].
53
+
This is enabled by the introduction of three new query plan operators: xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-dynamic-label-node-lookup[`DynamicLabelNodeLookup`], xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-dynamic-directed-relationship-type-lookup[`DynamicDirectedRelationshipTypeLookup`], and xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-dynamic-undirected-relationship-type-lookup[`DynamicUndirectedRelationshipTypeLookup`].
| For isolation purposes, `Eager` ensures that operations affecting subsequent operations are executed fully for the whole dataset before continuing execution.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc
+136Lines changed: 136 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2599,6 +2599,142 @@ Total database accesses: 106
2599
2599
2600
2600
======
2601
2601
2602
+
[role=label--new-2025.08]
2603
+
[[query-plan-dynamic-label-node-lookup]]
2604
+
=== Dynamic Label Node Lookup
2605
+
2606
+
Allows Cypher to use xref:indexes/search-performance-indexes/using-indexes.adoc#token-lookup-indexes[token lookup indexes] when planning queries using xref:clauses/match.adoc#dynamic-match[dynamic node labels].
Allows Cypher to use xref:indexes/search-performance-indexes/using-indexes.adoc#token-lookup-indexes[token lookup indexes] when planning queries using xref:clauses/match.adoc#dynamic-match[dynamic relationship types] in directed relationship patterns.
Allows Cypher to use xref:indexes/search-performance-indexes/using-indexes.adoc#token-lookup-indexes[token lookup indexes] when planning queries using dynamic relationship types in undirected relationship patterns.
0 commit comments