You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a question regarding caching some AQL subqueries on coordinator.
I'm traversing a tree structure recursively, like
for step1Doc,step1Edge,step1Path in 1..1 INBOUND root edges
let step1Children = (
// subquery call
for step2Doc,step2Edge,step2Path in 1..1 INBOUND step1Doc edges
// subquery call
let step2Children = (
// subquery call
for step3Doc,step3Edge,step3Path in 1..1 INBOUND step2Doc edges
// subquery call
let step3Children = (
// subquery call
for step4Doc,step4Edge,step4Path in 1..1 INBOUND step3Doc edges
return distinct step4Doc
)
return step3Children
)
...
)
And also I have a separate collection with additional metadata (static) related to the each vertex, which is a really small one (about 200 elements). I wish to query this collection for each node on each level to add some data to the result, but doing it drastically increase execution time (from 9 sec. to a minute)
The problem is that the subquery is being evaluated each time for each vertex and too many connections is spawned between coordinator and dbs. It's clearly seen in the profiler report:
Another bad side effect is that network load is too high.
Expected result:
So, I'm looking for some kind of memoize operation or any other way to explicitly evaluate and the result of subquery, or for some way to preload these kind of collections to the coordinator before the query starts.
Actually, I can execute 3 different queries and then aggregate the results somewhere on the backend if there's no way to get job done inside arangodb.
UPD:
Actually I figured out the next trick. I added next line on the top of the query:
let collectionResults = true ? (subquery) : []
This forced execution of the query on startup and same results are reused.
The text was updated successfully, but these errors were encountered:
dan1els
changed the title
AQL memoize subquery or preloading collection on coordinator before executing query
AQL memoize subquery or pre-load collection to coordinator before executing query
Sep 29, 2022
My Environment
Component, Query & Data
Affected feature:
AQL
Size of your Dataset on disk:
~70Gb
Problem:
I have a question regarding caching some AQL subqueries on coordinator.
I'm traversing a tree structure recursively, like
And also I have a separate collection with additional metadata (static) related to the each vertex, which is a really small one (about 200 elements). I wish to query this collection for each node on each level to add some data to the result, but doing it drastically increase execution time (from 9 sec. to a minute)
The problem is that the subquery is being evaluated each time for each vertex and too many connections is spawned between coordinator and dbs. It's clearly seen in the profiler report:
Results without subquery:
Results with subquery:
Another bad side effect is that network load is too high.
Expected result:
So, I'm looking for some kind of memoize operation or any other way to explicitly evaluate and the result of subquery, or for some way to preload these kind of collections to the coordinator before the query starts.
Actually, I can execute 3 different queries and then aggregate the results somewhere on the backend if there's no way to get job done inside arangodb.
UPD:
Actually I figured out the next trick. I added next line on the top of the query:
This forced execution of the query on startup and same results are reused.
The text was updated successfully, but these errors were encountered: