问题描述
海王星上的 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."
}
我的问题:
解决方法
添加 limit(1) 来限制结果的大小已解决问题。
g.V().hasLabel('MyVertex').has('myLabel',1234).outE().hasLabel('MY_EDGE_LABEL').count().limit(1).next()