您好,我是ArangoDB的新手。
就我而言,下面有收藏品。
他们的藏品彼此相关,在
之下所以我希望所有广播加入所有集合,如下面的查询。
FOR b IN broadcast
return MERGE(b, {
character : (
FOR c IN 1..1 OUTBOUND b._id broadcastToCharacter
return c
),
videoGroup : (
FOR s IN 1..1 OUTBOUND b._id broadcastToVideoGroup
return merge(s, {
episodes : (
FOR e IN 1..1 OUTBOUND s._id videoGroupToEpisode
return merge(e, {
clips : (
FOR c IN 1..1 OUTBOUND e._id episodeToClip
return c
)
})
)
})
)
})
我希望加入所有数据进行广播,如下所示
[{
title : "office season3",
// and some other broadcast properties
character : [{
"role" : "Dwight", ...
},...],
videoGroup : [{
groupId : 123,
// and some other videoGroup properties
episodes : [{
episodeName : "Ep01. foobar",
// and some other episode properties
clips : [{
clipName : "First Season foobar!",
// and some other clip properties
}, ...]
}, ...]
},...]
},...]
但查询太慢,执行时间超过10秒。以下是我对上述查询的解释 查询字符串:
FOR b IN broadcast return MERGE(b, {character : (FOR c IN 1..1 OUTBOUND b._id broadcastToCharacter return
c),videoGroup : (FOR s IN 1..1 OUTBOUND b._id broadcastToVideoGroup return merge(s, {episodes : (FOR e IN 1..1
OUTBOUND s._id videoGroupToEpisode return merge(e, { clips : ...
Execution plan:
Id NodeType Est. Comment
1 SingletonNode 1 * ROOT
2 EnumerateCollectionNode 24518 - FOR b IN broadcast /* full collection scan */
7 SubqueryNode 24518 - LET #2 = ... /* subquery */
3 SingletonNode 1 * ROOT
4 CalculationNode 1 - LET #13 = b.`_id` /* attribute expression */ /* collections used: b : broadcast */
5 TraversalNode 5 - FOR c /* vertex */ IN 1..1 /* min..maxPathDepth */ OUTBOUND #13 /* startnode */ broadcastToCharacter
6 ReturnNode 5 - RETURN c
24 SubqueryNode 24518 - LET #11 = ... /* subquery */
8 SingletonNode 1 * ROOT
9 CalculationNode 1 - LET #17 = b.`_id` /* attribute expression */ /* collections used: b : broadcast */
10 TraversalNode 1 - FOR s /* vertex */ IN 1..1 /* min..maxPathDepth */ OUTBOUND #17 /* startnode */ broadcastToVideoGroup
21 SubqueryNode 1 - LET #9 = ... /* subquery */
11 SingletonNode 1 * ROOT
12 CalculationNode 1 - LET #21 = s.`_id` /* attribute expression */
13 TraversalNode 25 - FOR e /* vertex */ IN 1..1 /* min..maxPathDepth */ OUTBOUND #21 /* startnode */ videoGroupToEpisode
18 SubqueryNode 25 - LET #7 = ... /* subquery */
14 SingletonNode 1 * ROOT
15 CalculationNode 1 - LET #25 = e.`_id` /* attribute expression */
16 TraversalNode 8 - FOR c /* vertex */ IN 1..1 /* min..maxPathDepth */ OUTBOUND #25 /* startnode */ episodeToClip
17 ReturnNode 8 - RETURN c
19 CalculationNode 25 - LET #29 = MERGE(e, { "clips" : #7 }) /* simple expression */
20 ReturnNode 25 - RETURN #29
22 CalculationNode 1 - LET #31 = MERGE(s, { "episodes" : #9 }) /* simple expression */
23 ReturnNode 1 - RETURN #31
25 CalculationNode 24518 - LET #33 = MERGE(b, { "character" : #2, "videoGroup" : #11 }) /* simple expression */ /* collections used: b : broadcast */
26 ReturnNode 24518 - RETURN #33
Indexes used:
By Type Collection Unique Sparse Selectivity Fields Ranges
5 edge broadcastToCharacter false false 19.42 % [ `_from` ] base OUTBOUND
10 edge broadcastToVideoGroup false false 90.89 % [ `_from` ] base OUTBOUND
13 edge videoGroupToEpisode false false 3.99 % [ `_from` ] base OUTBOUND
16 edge episodeToClip false false 11.55 % [ `_from` ] base OUTBOUND
Traversals on graphs:
Id Depth Vertex collections Edge collections Options Filter conditions
5 1..1 broadcastToCharacter uniqueVertices: none, uniqueEdges: path
10 1..1 broadcastToVideoGroup uniqueVertices: none, uniqueEdges: path
13 1..1 videoGroupToEpisode uniqueVertices: none, uniqueEdges: path
16 1..1 episodeToClip uniqueVertices: none, uniqueEdges: path
Optimization rules applied:
none