arangodb - 在 ArangoDB 中使用顶点和边 VS 连接时的性能差异
问题描述
下面是一些细节。
查询 1:也使用 Graph Traversal 附加的执行计划。
在这里,我使用 CollectionA 和 CollectionB 之间的边缘。
请求参数:
for u in CollectionA filter u.FilterA == @opId and u.FilterB >= @startTimeInLong and u.FilterB <= @endTimeInLong for v in 1..1 OUTBOUND u CollectionALinksCollectionB filter v.FilterC == null return v Execution plan: Id NodeType Est. Comment 1 SingletonNode 1 * ROOT 9 IndexNode 45088 - FOR u IN CollectionA /* skiplist index scan */ 5 TraversalNode 1 - FOR v /* vertex */ IN 1..1 /* min..maxPathDepth */ OUTBOUND u /* startnode */ CollectionALinksCollectionB 6 CalculationNode 1 - LET #6 = (v.`ReceivedRating` == null) /* simple expression */ 7 FilterNode 1 - FILTER #6 8 ReturnNode 1 - RETURN v Indexes used: By Type Collection Unique Sparse Selectivity Fields Ranges 9 skiplist CollectionA false false 100.00 % [ `FilterA`, `FilterB` ] ((u.`FilterA` == "8277") && (u.`FilterB` >= 1526947200000) && (u.`FilterB` <= 1541030400000)) 5 edge CollectionALinksCollectionB false false 100.00 % [ `_from` ] base OUTBOUND Traversals on graphs: Id Depth Vertex collections Edge collections Options Filter conditions 5 1..1 CollectionALinksCollectionB uniqueVertices: none, uniqueEdges: path Optimization rules applied: Id RuleName 1 use-indexes 2 remove-filter-covered-by-index 3 remove-unnecessary-calculations-2
查询 2:
Query string:
for u in CollectionA filter u.FilterA == @opId and u.FilterB >= @startTimeInLong and
u.FilterB <= @endTimeInLong
for v in CollectionB
filter
v._key==u._key and
v.FilterC == null return v
Execution plan:
Id NodeType Est. Comment
1 SingletonNode 1 * ROOT
8 CalculationNode 1 - LET #6 = CollectionB /* all collection documents */ /* v8 expression */
11 IndexNode 45088 - FOR u IN CollectionA /* skiplist index scan */
10 IndexNode 45088 - FOR v IN CollectionB /* primary index scan, scan only */
12 CalculationNode 45088 - LET #4 = (CollectionB /* all collection documents */.`FilterC` == null) /* v8 expression */
7 FilterNode 45088 - FILTER #4
9 ReturnNode 45088 - RETURN #6
Indexes used:
By Type Collection Unique Sparse Selectivity Fields Ranges
11 skiplist CollectionA false false 100.00 % [ `FilterA`, `FilterB` ] ((u.`FilterA` == "8277") && (u.`FilterB` >= 1526947200000) && (u.`FilterB` <= 1541030400000))
10 primary CollectionB true false 100.00 % [ `_key` ] (CollectionB.`_key` == u.`_key`)
Optimization rules applied:
Id RuleName
1 move-calculations-up
2 use-indexes
3 remove-filter-covered-by-index
4 remove-unnecessary-calculations-2
查询 1 的性能如何优于查询 2。此外,对于较小的数据集,查询结果几乎相似,但对于较大的数据,查询 1 的性能更好。
有人可以详细解释一下 Graph traversing 在这里有什么帮助吗
解决方案
推荐阅读
- c# - .NET Core 2.0 网页将数据保存在缓存中
- c# - Entity Framework Core 2 自动生成的列
- c# - 我需要在 c# 中以异步方式多次执行一种方法
- c# - .NET 程序中补充 MongoDB 的文件系统机制
- javascript - React Native - 如何从子组件调用函数?
- excel - Excel VBA仅突出显示带有变量的一列
- objective-c - 如何在 Swift 中添加 RNCryptor
- javascript - 数据表内置按钮固定位置
- crystal-reports - Crystal Reports 2016 交叉表根据条件可用的指定列的值抑制行
- javascript - 手机拖拽问题