Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit 82c6e6d

Browse files
authored
Added support for indexHint and forceIndexHint to UPSERT - APM-121 (#776)
1 parent 39aa481 commit 82c6e6d

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

3.9/aql/operations-upsert.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,35 @@ FOR i IN 1..1000
129129
IN users OPTIONS { exclusive: true }
130130
```
131131

132+
### `indexHint`
133+
134+
The `indexHint` option will be used as a hint for the document lookup
135+
performed as part of the `UPSERT` operation, and can help in cases such as
136+
`UPSERT` not picking the best index automatically.
137+
138+
```js
139+
UPSERT { a: 1234 }
140+
INSERT { a: 1234, name: "AB" }
141+
UPDATE { name: "ABC" } IN myCollection
142+
OPTIONS { indexHint: "index_name" }
143+
```
144+
145+
The index hint is passed through to an internal `FOR` loop that is used for the
146+
lookup. Also see [`indexHint` Option of the `FOR` Operation](operations-for.html#indexhint).
147+
148+
### `forceIndexHint`
149+
150+
Makes the index or indices specified in `indexHint` mandatory if enabled. The
151+
default is `false`. Also see
152+
[`forceIndexHint` Option of the `FOR` Operation](operations-for.html#forceindexhint).
153+
154+
```js
155+
UPSERT { a: 1234 }
156+
INSERT { a: 1234, name: "AB" }
157+
UPDATE { name: "ABC" } IN myCollection
158+
OPTIONS { indexHint: … , forceIndexHint: true }
159+
```
160+
132161
Returning documents
133162
-------------------
134163

3.9/release-notes-new-features39.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ and later used as a condition for `FILTER`.
9797

9898
See [Pruning](aql/graphs-traversals.html#pruning)
9999

100+
### Upsert with Index Hint
101+
102+
Added support for the `indexHint` and `forceIndexHint` options to the `UPSERT`
103+
operation. It will be used as a hint for the document lookup that is performed
104+
as part of the `UPSERT` operation, and can help in cases such as `UPSERT` not
105+
picking the best index automatically.
106+
107+
```js
108+
UPSERT { a: 1234 }
109+
INSERT { a: 1234, name: "AB"}
110+
UPDATE {name: "ABC"} IN myCollection
111+
OPTIONS { indexHint: "index_name", forceIndexHint: true }
112+
```
113+
114+
See [`UPSERT` Options](aql/operations-upsert.html#indexhint)
115+
100116
### Decay Functions
101117

102118
Added three decay functions to AQL:

0 commit comments

Comments
 (0)