Skip to content

Commit 78aff0f

Browse files
nerpaulaSimran-B
andauthored
DOC-614 | Added readOwnWrites option for UPSERT operations (#409)
* added readOwnWrites option for UPSERT * Apply suggestions from code review Co-authored-by: Simran <Simran-B@users.noreply.github.com> * rephrase Co-authored-by: Simran <Simran-B@users.noreply.github.com> --------- Co-authored-by: Simran <Simran-B@users.noreply.github.com>
1 parent 1ad6cdd commit 78aff0f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

site/content/3.12/aql/high-level-operations/upsert.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,20 @@ UPSERT { a: 1234 }
243243
OPTIONS { indexHint: … , forceIndexHint: true }
244244
```
245245

246+
### `readOwnWrites`
247+
248+
The `readOwnWrites` option allows an `UPSERT` operation to process its inputs one
249+
by one. The default value is `true`. When enabled, the `UPSERT` operation can
250+
observe its own writes and can handle modifying the same target document multiple
251+
times in the same query.
252+
253+
When the option is set to `false`, an `UPSERT` operation processes its inputs
254+
in batches. Normally, a batch has 1000 inputs, which can lead to a faster execution.
255+
However, when using batches, the `UPSERT` operation can essentially not observe its own writes.
256+
You should only set the `readOwnWrites` option to `false` if you can
257+
guarantee that the input of the `UPSERT` leads to disjoint documents being
258+
inserted, updated, or replaced.
259+
246260
## Returning documents
247261

248262
`UPSERT` statements can optionally return data. To do so, they need to be followed

site/content/3.12/release-notes/version-3.12/whats-new-in-3-12.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,21 @@ UPDATE { logins: OLD.logins + 1 } IN users
175175

176176
Read more about [`UPSERT` operations](../../aql/high-level-operations/upsert.md) in AQL.
177177

178+
### `readOwnWrites` option for `UPSERT` operations
179+
180+
A `readOwnWrites` option has been added for `UPSERT` operations. The default
181+
value is `true` and the behavior is identical to previous versions of ArangoDB that
182+
do not have this option. When enabled, an `UPSERT` operation processes its
183+
inputs one by one. This way, the operation can observe its own writes and can
184+
handle modifying the same target document multiple times in the same query.
185+
186+
When the option is set to `false`, an `UPSERT` operation processes its inputs
187+
in batches. Normally, a batch has 1000 inputs, which can lead to a faster execution.
188+
However, when using batches, the `UPSERT` operation cannot observe its own writes.
189+
Therefore, you should only set the `readOwnWrites` option to `false` if you can
190+
guarantee that the input of the `UPSERT` leads to disjoint documents being
191+
inserted, updated, or replaced.
192+
178193
### Added AQL functions
179194

180195
The new `PARSE_COLLECTION()` and `PARSE_KEY()` let you more extract the

0 commit comments

Comments
 (0)