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

Commit 81be533

Browse files
authored
Add limits for AQL query complexity (#726)
1 parent 2aef30f commit 81be533

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

3.9/aql/extending-conventions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ purely functional and thus free of side effects and state, and state modificatio
3737

3838
{% hint 'warning' %}
3939
Modification of global variables is unsupported, as is reading or changing
40-
the data of any collection from inside an AQL user function.
40+
the data of any collection or running queries from inside an AQL user function.
4141
{% endhint %}
4242

4343
User function code is late-bound, and may thus not rely on any variables

3.9/aql/extending.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ To overcome these mentioned limitations, you may want to increase the
5959
(at the expense of increased memory usage), and the
6060
[number of available server threads](../programs-arangod-server.html#server-threads).
6161

62+
In addition, modification of global JavaScript variables from inside UDFs is
63+
unsupported, as is reading or changing the data of any collection or running
64+
queries from inside an AQL user function.
65+
6266
### Deployment Details
6367

6468
Internally, UDFs are stored in a system collection named `_aqlfunctions`

3.9/aql/fundamentals-limitations.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ description: Known limitations that apply in AQL queries
55
Known limitations for AQL queries
66
=================================
77

8-
The following limitations are known for AQL queries:
8+
The following hard-coded limitations exist for AQL queries:
99

1010
- An AQL query cannot use more than _1000_ result registers.
1111
One result register is needed for every named query variable and for
1212
internal/anonymous query variables.
13+
- An AQL query cannot have more than _4000_ execution nodes in its initial
14+
query execution plan.
1315
- An AQL query cannot use more than _2048_ collections/shards.
1416
- It is not possible to use a collection in a read operation after
1517
it was used for a write operation in the same AQL query.
@@ -18,6 +20,18 @@ The following limitations are known for AQL queries:
1820
[`DOCUMENT()` function](functions-miscellaneous.html#document) or
1921
[traversals working with collection sets](graphs-traversals.html#working-with-collection-sets)
2022
(instead of named graphs).
23+
- Expressions in AQL queries cannot have a nesting of more than _500_ levels.
24+
As an example, the expression `1 + 2 + 3 + 4` is 3 levels deep
25+
(because it is interpreted and executed as `1 + (2 + (3 + 4))`).
26+
27+
Please note that even queries that are still below these limits may not
28+
yield good performance, especially when they have to put together data from lots
29+
of different collections. Please also consider that large queries (in terms of
30+
intermediate result size or final result size) can use considerable amounts of
31+
memory and may hit the configurable memory limits for AQL queries.
32+
33+
The following other limitations are known for AQL queries:
34+
2135
- Subqueries that are used inside expressions are pulled out of these
2236
expressions and executed beforehand. That means that subqueries do not
2337
participate in lazy evaluation of operands, for example in the

3.9/release-notes-upgrading-changes39.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ now expected to be present on all targets that run ArangoDB 3.9 executables.
1919
If a target does not support AVX instructions, it may fail with SIGILL at
2020
runtime.
2121

22+
AQL
23+
---
24+
25+
The following complexity limits have been added in 3.9 for AQL queries,
26+
Additional complexity limits have been added for AQL queries, in order to
27+
prevent programmatically generated large queries from causing trouble
28+
(too deep recursion, enormous memory usage, long query optimization
29+
and distribution passes etc.).
30+
31+
The following limits have been added:
32+
33+
- a recursion limit for AQL query expressions. An expression can now be
34+
up to 500 levels deep. An example expression is `1 + 2 + 3 + 4`, which
35+
is 3 levels deep `1 + (2 + (3 + 4))`.
36+
The recursion of expressions is limited to 500 levels.
37+
- a limit for the number of execution nodes in the initial query
38+
execution plan. The number of execution nodes is limited to 4,000.
39+
40+
Also see [Known limitations for AQL queries](aql/fundamentals-limitations.html).
41+
2242
Startup options
2343
---------------
2444

3.9/release-notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ For a detailed list of changes to the ArangoDB core programs and tools,
3838
please refer to the version specific changelogs:
3939

4040
- Changelogs 3.x:
41-
[3.8](https://raw.githubusercontent.com/arangodb/arangodb/3.9/CHANGELOG){:target="_blank"},
41+
[3.9](https://raw.githubusercontent.com/arangodb/arangodb/3.9/CHANGELOG){:target="_blank"},
4242
[3.8](https://raw.githubusercontent.com/arangodb/arangodb/3.8/CHANGELOG){:target="_blank"},
4343
[3.7](https://raw.githubusercontent.com/arangodb/arangodb/3.7/CHANGELOG){:target="_blank"},
4444
[3.6](https://raw.githubusercontent.com/arangodb/arangodb/3.6/CHANGELOG){:target="_blank"},
@@ -72,7 +72,7 @@ Also see [Version Specific Upgrade Information](upgrading-version-specific.html)
7272
in the _Upgrading_ chapter.
7373

7474
- Incompatible changes in 3.x:
75-
[3.8](release-notes-upgrading-changes39.html),
75+
[3.9](release-notes-upgrading-changes39.html),
7676
[3.8](release-notes-upgrading-changes38.html),
7777
[3.7](release-notes-upgrading-changes37.html),
7878
[3.6](release-notes-upgrading-changes36.html),

0 commit comments

Comments
 (0)