【问题标题】:Optimize traversal and look up in gremlin query of connected components优化连接组件的gremlin查询中的遍历和查找
【发布时间】:2021-07-22 14:54:34
【问题描述】:

我试图在图中找到一个连接组件中的所有节点,其中包含大约 130M 的顶点和大约 350M 的边。

以下是我用来查找连接组件中节点数的查询 -

输入 - 起始顶点 ID/名称

输出 - 连接组件中的节点数。

查询 - g.v().has("name", "driver1").repeat(where(without ("a")).store("a").both().simplePath().dedup()).emit().hasLabel("driver").count().fold()

上述查询大约需要 52 秒

RepeatStep 大约需要 29 秒

有没有一种方法可以优化 Repeatstep 中的线性遍历或 WherePredicateatep 中的查找?

上述查询的配置文件输出-

"dur": 29008.200345, "counts": ("traverserCount": 13809,"elementCount": 13809}, name: "RepeatStep ([Where PredicateStep (without ([a])), Profilestep, Storestep (a), Profilestep, JanuaGraphVertexStep(BOTH, vertex), ProfileStep, PathFilterstep(simple), Profilestep, RepeatEndstep, Profilestep], until(false), emit(true))", "annotations":{ "percentDur": 52.557919400750215}, "id": "2.0.0()", "metrics": [ { "dur": 38.137699, "counts":{ traverserCount: 13810, elementCount: 13810}, "name":"WherePredicateStep(without([a]))", "id": "0.1.0 (2.0.0())" }, { "dur": 28628.594393, "counts": { "traverserCount": 252428, "elementCount": 252428 }, name: "JanusGraphVertexStep (BOTH, vertex)", "annotations"

【问题讨论】:

  • 对于您在此处询问 groups.google.com/g/gremlin-users/c/x3HwF_Ocr5g
  • 是的,但是我还没有收到满意的回复,所以我也想在这里发布。
  • 我会添加一个答案,但它与 Gremlin-Users 中发布的答案相似。

标签: gremlin janusgraph amazon-neptune gremlin-server connected-components


【解决方案1】:

图形查询的性能取决于需要触及的数据量以及索引可以提供的帮助量。配置文件结果中的遍历器计数向您显示有多少数据被触及(本质上是查询的扇出)。如果您使用 JanusGraph,查询的 .profile() 将显示索引提供了多少帮助(或不提供)。如果您使用的是 Amazon Neptune,为 both 和 in 等步骤提供标签有助于查询引擎利用可用索引。在某些情况下,多线程查询并将结果加入应用程序会有所帮助。在您的情况下,如果不知道您的数据的确切构成,就很难给出额外的建议。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-26
    • 1970-01-01
    • 1970-01-01
    • 2015-05-19
    • 1970-01-01
    • 2020-09-17
    • 2016-08-08
    • 1970-01-01
    相关资源
    最近更新 更多