Skip to content

DOC-614 | Added readOwnWrites option for UPSERT operations #409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions site/content/3.12/aql/high-level-operations/upsert.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@ UPSERT { a: 1234 }
OPTIONS { indexHint: … , forceIndexHint: true }
```

### `readOwnWrites`

The `readOwnWrites` option allows an `UPSERT` operation to process its inputs one
by one. The default value is `true`. When enabled, the `UPSERT` operation can
observe its own writes and can handle modifying the same target document multiple
times in the same query.

When the option is set to `false`, an `UPSERT` operation processes its inputs
in batches. Normally, a batch has 1000 inputs, which can lead to a faster execution.
However, when using batches, the `UPSERT` operation can essentially not observe its own writes.
You should only set the `readOwnWrites` option to `false` if you can
guarantee that the input of the `UPSERT` leads to disjoint documents being
inserted, updated, or replaced.

## Returning documents

`UPSERT` statements can optionally return data. To do so, they need to be followed
Expand Down
15 changes: 15 additions & 0 deletions site/content/3.12/release-notes/version-3.12/whats-new-in-3-12.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,21 @@ UPDATE { logins: OLD.logins + 1 } IN users

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

### `readOwnWrites` option for `UPSERT` operations

A `readOwnWrites` option has been added for `UPSERT` operations. The default
value is `true` and the behavior is identical to previous versions of ArangoDB that
do not have this option. When enabled, an `UPSERT` operation processes its
inputs one by one. This way, the operation can observe its own writes and can
handle modifying the same target document multiple times in the same query.

When the option is set to `false`, an `UPSERT` operation processes its inputs
in batches. Normally, a batch has 1000 inputs, which can lead to a faster execution.
However, when using batches, the `UPSERT` operation cannot observe its own writes.
Therefore, you should only set the `readOwnWrites` option to `false` if you can
guarantee that the input of the `UPSERT` leads to disjoint documents being
inserted, updated, or replaced.

### Added AQL functions

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