用于计算边数的 Gremlin 查询 - MemoryLimitExceededException AWS Neptune

问题描述

海王星上的 Gremlin 查询以计算具有特定标签的顶点的边数,结果为 MemoryLimitExceededException错误只发生几次,即如果我运行查询 10 次,则成功两次。

海王星正在使用 db.r5.xlarge

查询

g.V().hasLabel('MyVertex').has('myLabel',1234).outE().hasLabel('MY_EDGE_LABEL').count().next()

标签MyVertex 的顶点超过 300 万个,与 MY_EDGE_LABEL标签匹配的边有 100 万条。

错误

{
    "code": "MemoryLimitExceededException","requestId": "123456-abcd-1234-1234-11aa221122ab","detailedMessage": "Query cannot be completed due to memory limitations."
}

我的问题:

  • 在 Neptune 上是否有任何可以增加查询的内存限制之类的设置?
  • 是否可以调整查询中的任何内容以获得相同的结果但消耗更少的内存。

解决方法

添加 limit(1) 来限制结果的大小已解决问题。

g.V().hasLabel('MyVertex').has('myLabel',1234).outE().hasLabel('MY_EDGE_LABEL').count().limit(1).next()