【问题标题】:Foxx arangodb runs into memory limitFoxx arangodb 遇到内存限制
【发布时间】:2020-04-29 11:51:52
【问题描述】:

我在 foxx 中运行了一个简单的查询

For u in collection
Filter u.someIndexedSparseFiler !=null
Return {_id:u._id}

这将返回数百万以上的结果。在日志中,arango 有一条消息到达有限的内存堆并终止进程。

reached heap-size limit of #3 interrupting V8 execution (heap size limit 3232954528, used 3060226424) during V8 internal collection

即使我在启动时添加了标志 --javascript.v8-max-heap 3000。它仍然在相同的错误中运行。我该怎么办?有没有比这更好的方法

【问题讨论】:

    标签: arangodb aql foxx


    【解决方案1】:

    我不确定您为什么会出现内存不足错误,但您返回的数据似乎超出了 V8 堆大小。另一种可能性是某些原因导致引擎错过/忽略索引,导致引擎在评估 someIndexedSparseFiler 属性之前加载每个文档。

    评估数百万个文档(或大量大型文档)不仅会消耗大量磁盘/内存 I/O,而且还可能需要大量 RAM。尝试使用 explain 功能返回查询分析 - 它应该会告诉您出了什么问题。

    为了比较,我的查询...

    FOR u IN myCollection
        FILTER u.someIndexedSparseFiler != null
        RETURN u._id
    

    ...当我点击“解释”时返回这个:

    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 值,所以它会跳过它。

    如果您不熟悉它,“解释”功能在调整查询和创建索引时非常有用(实际上是必不可少的)。另外,请记住索引应该与您的查询匹配;在这种情况下,索引应该只有一个属性,否则“选择性”商可能太低,引擎将忽略它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多