From 76754bf5b45edb0d26fa003b300592df36ae4fb2 Mon Sep 17 00:00:00 2001 From: Pontus Melke Date: Tue, 11 Nov 2025 16:52:49 +0100 Subject: [PATCH 1/3] Add documentation for MergeInto (#1422) Co-authored-by: Stefano Ottolenghi --- .../operators/operators-detail.adoc | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc b/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc index 30e9edece..301dfd841 100644 --- a/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc +++ b/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc @@ -6035,6 +6035,57 @@ Total database accesses: 4, total allocated memory: 184 ====== +[query-plan-merge-into]] +=== Merge Into + +The `MergeInto` operator is similar to the xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-merge[`Merge`] operator, but is used when the start and end node of the pattern is matched outside the `MERGE` pattern. + +If necessary, the operator locks the pattern nodes before creating the relationship, to avoid creating multiple relationships between the nodes. + + +.MergeInto +====== + +.Query +[source, cypher] +---- +PROFILE +MATCH (s:Person {name: 'me'}) +MERGE (s)-[:FRIENDS_WITH]->(s) +---- + +.Query Plan +[role="queryplan", subs="attributes+"] +---- +Planner COST + +Runtime PIPELINED + +Runtime version {neo4j-version} + +Batch size 128 + ++-----------------+----+-------------------------------------------------------+----------------+------+---------+----------------+------------------------+-----------+---------------------+----------------------+ +| Operator | Id | Details | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Page Cache Hits/Misses | Time (ms) | Pipeline | Indexes Used | ++-----------------+----+-------------------------------------------------------+----------------+------+---------+----------------+------------------------+-----------+---------------------+----------------------+ +| +ProduceResults | 0 | | 1 | 0 | 0 | 0 | | | | | +| | +----+-------------------------------------------------------+----------------+------+---------+----------------+ | | +----------------------+ +| +EmptyResult | 1 | | 1 | 0 | 0 | | | | | | +| | +----+-------------------------------------------------------+----------------+------+---------+----------------+ | | +----------------------+ +| +Apply | 2 | | 1 | 1 | 0 | | | | | | +| |\ +----+-------------------------------------------------------+----------------+------+---------+----------------+ | | +----------------------+ +| | +MergeInto | 3 | MERGE (s)-[anon_0:FRIENDS_WITH]->(s) | 1 | 1 | 1 | | | | | | +| | | +----+-------------------------------------------------------+----------------+------+---------+----------------+ | | +----------------------+ +| | +Argument | 4 | s | 1 | 1 | 0 | 2288 | 1/0 | 0.673 | Fused in Pipeline 1 | | +| | +----+-------------------------------------------------------+----------------+------+---------+----------------+------------------------+-----------+---------------------+----------------------+ +| +NodeIndexSeek | 5 | RANGE INDEX s:Person(name) WHERE name = $autostring_0 | 1 | 1 | 2 | 376 | 1/0 | 0.256 | In Pipeline 0 | range_person_name: 1 | ++-----------------+----+-------------------------------------------------------+----------------+------+---------+----------------+------------------------+-----------+---------------------+----------------------+ + +Total database accesses: 15, total allocated memory: 2232 +---- + +====== + [[query-plan-locking-merge]] === Locking Merge From 96f4629e0638b1e0b4eedecf6ed330e816e3f20d Mon Sep 17 00:00:00 2001 From: Stefano Ottolenghi Date: Mon, 17 Nov 2025 15:29:59 +0100 Subject: [PATCH 2/3] typo --- .../pages/planning-and-tuning/operators/operators-detail.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc b/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc index 301dfd841..1bca2294e 100644 --- a/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc +++ b/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc @@ -6035,7 +6035,7 @@ Total database accesses: 4, total allocated memory: 184 ====== -[query-plan-merge-into]] +[[query-plan-merge-into]] === Merge Into The `MergeInto` operator is similar to the xref:planning-and-tuning/operators/operators-detail.adoc#query-plan-merge[`Merge`] operator, but is used when the start and end node of the pattern is matched outside the `MERGE` pattern. From a5315167335355cb777182e520e3ced847104622 Mon Sep 17 00:00:00 2001 From: Stefano Ottolenghi Date: Thu, 20 Nov 2025 16:58:57 +0100 Subject: [PATCH 3/3] Update operators-detail.adoc --- .../pages/planning-and-tuning/operators/operators-detail.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc b/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc index 1bca2294e..bdd7b1184 100644 --- a/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc +++ b/modules/ROOT/pages/planning-and-tuning/operators/operators-detail.adoc @@ -6035,6 +6035,7 @@ Total database accesses: 4, total allocated memory: 184 ====== +[role=label--new-2025.11] [[query-plan-merge-into]] === Merge Into