为什么这个简单的 ArangoDB 查询有时需要很长时间
Why this simple ArangoDB query sometimes takes very long time
我正在使用这个非常简单的查询
通过arangojs.query()
查询大约 500k 文档的 ArangoDb
"FOR c IN Entity FILTER c.id == 261764 RETURN c"
它是node-link图中的一个节点。
但有时,它花费了 10 多秒,并且在 arangodb 的日志中也有关于查询花费太 long.Lots 时间的警告,如果在浏览器上使用新会话,就会发生这种情况。是arangodb还是arangojs的问题还是我查询本身没有优化?
--------------------编辑---------------------
已添加 db.explain
Query string:
FOR c IN Entity FILTER c.id == 211764 RETURN c
Execution plan:
Id NodeType Est. Comment
1 SingletonNode 1 * ROOT
2 EnumerateCollectionNode 140270 - FOR c IN Entity /* full collection scan */
3 CalculationNode 140270 - LET #1 = (c.`id` == 211764) /* simple expression */ /* collections used: c : Entity */
4 FilterNode 140270 - FILTER #1
5 ReturnNode 140270 - RETURN c
使用的索引:
none
已应用优化规则:
none
如您的解释所示,您的查询没有使用索引,而是进行了完整的集合扫描。
根据找到匹配项的时间(在集合的开始或结束时),执行时间可能会有所不同。
参见 the Indexing chapter for creating indices, and the AQL Execution and Performance 章节如何分析 db._explain()
的输出
我正在使用这个非常简单的查询
通过arangojs.query()
查询大约 500k 文档的 ArangoDb
"FOR c IN Entity FILTER c.id == 261764 RETURN c"
它是node-link图中的一个节点。
但有时,它花费了 10 多秒,并且在 arangodb 的日志中也有关于查询花费太 long.Lots 时间的警告,如果在浏览器上使用新会话,就会发生这种情况。是arangodb还是arangojs的问题还是我查询本身没有优化?
--------------------编辑---------------------
已添加 db.explain
Query string:
FOR c IN Entity FILTER c.id == 211764 RETURN c
Execution plan:
Id NodeType Est. Comment
1 SingletonNode 1 * ROOT
2 EnumerateCollectionNode 140270 - FOR c IN Entity /* full collection scan */
3 CalculationNode 140270 - LET #1 = (c.`id` == 211764) /* simple expression */ /* collections used: c : Entity */
4 FilterNode 140270 - FILTER #1
5 ReturnNode 140270 - RETURN c
使用的索引:
none
已应用优化规则:
none
如您的解释所示,您的查询没有使用索引,而是进行了完整的集合扫描。
根据找到匹配项的时间(在集合的开始或结束时),执行时间可能会有所不同。
参见 the Indexing chapter for creating indices, and the AQL Execution and Performance 章节如何分析 db._explain()