我在foxx中有一个简单的查询运行。
For u in collection
Filter u.someIndexedSparseFiler !=null
Return {_id:u._id}这将返回millions+结果。在日志中,arango有一条到达并终止进程的有限内存堆的消息。
reached heap-size limit of #3 interrupting V8 execution (heap size limit 3232954528, used 3060226424) during V8 internal collection即使我将标志--javascript.v8-max-堆3000添加到启动程序中。它仍然运行在相同的错误中。我该怎么办?有没有比这更好的方法
发布于 2020-05-22 04:50:16
我不知道为什么会出现内存不足的错误,但您返回的数据似乎超出了V8堆的大小。另一种可能是,某些东西导致引擎遗漏/忽略索引,导致引擎在计算someIndexedSparseFiler属性之前加载每个文档。
评估数百万个文档(或大量大型文档)不仅需要大量的磁盘/内存I/O,而且还需要大量的RAM。尝试使用解释特性返回查询分析--它应该会告诉您出了什么问题。
作为比较,我的查询..。
FOR u IN myCollection
FILTER u.someIndexedSparseFiler != null
RETURN u._id当我单击“解释”时,...returns:
Query String (82 chars, cacheable: true):
FOR u IN myCollection
FILTER u.someIndexedSparseFiler != null
RETURN u._id
Execution plan:
Id NodeType Est. Comment
1 SingletonNode 1 * ROOT
7 IndexNode 5 - FOR u IN myCollection /* persistent index scan, projections: `_id` */
5 CalculationNode 5 - LET #3 = u.`_id` /* attribute expression */ /* collections used: u : myCollection */
6 ReturnNode 5 - RETURN #3
Indexes used:
By Name Type Collection Unique Sparse Selectivity Fields Ranges
7 idx_1667363882689101824 persistent myCollection false true 100.00 % [ `someIndexedSparseFiler` ] *
Optimization rules applied:
Id RuleName
1 move-calculations-up
2 move-filters-up
3 move-calculations-up-2
4 move-filters-up-2
5 use-indexes
6 remove-filter-covered-by-index
7 remove-unnecessary-calculations-2
8 reduce-extraction-to-projection注意,它在Indexes used:下面列出了我的稀疏索引。另外,尝试将!=更改为==,您将看到现在它忽略了索引!这是因为优化器知道稀疏索引永远不会有null值,所以它跳过了它。
如果您不熟悉它,那么“解释”功能在调优查询和创建索引时非常有用(确实是必不可少的)。另外,请记住索引应该与查询匹配;在这种情况下,索引应该只有一个属性,否则“选择”商可能太低,而引擎会忽略它。
https://stackoverflow.com/questions/61501172
复制相似问题