Janusgraph 为大多数查询提供超时

问题描述 投票:0回答:1

我使用 Janusgraph 0.6.3,以 cassandra 作为后端,以 elastic search 作为索引后端。我的图中有大约 3000 万个顶点和 4000 万个边,我使用的是 128 GB RAM 机器,具有 32 核 CPU,上面安装了 Janus 和 Cassandra。 (Elastic 托管在其他具有更好规格的机器上)。

我已经为我在 gremlin 查询中使用的属性定义了复合索引和混合索引,

Composite Index

management.buildIndex("seeker", Vertex.class).addKey(management.getPropertyKey("p_uuid"))
                .indexOnly(management.getVertexLabel("seeker"))
                .buildCompositeIndex();
        management.buildIndex("company", Vertex.class).addKey(management.getPropertyKey("company_name"))
                .indexOnly(management.getVertexLabel("company"))
                .buildCompositeIndex();
        management.buildIndex("start_date", Edge.class).addKey(management.getPropertyKey("start_date"))
                .indexOnly(management.getEdgeLabel("worked"))
                .buildCompositeIndex();
        management.buildIndex("end_date", Edge.class).addKey(management.getPropertyKey("end_date"))
                .indexOnly(management.getEdgeLabel("worked"))
                .buildCompositeIndex();

Mixed Index

management.buildIndex("vertex", Vertex.class).addKey(management.getPropertyKey("p_uuid"))
                .addKey(management.getPropertyKey("company_name"))
                .buildMixedIndex(this.graphCreds.getIndex_index_name());
        management.buildIndex("edge", Edge.class).addKey(management.getPropertyKey("start_date"))
                .addKey(management.getPropertyKey("end_date"))
                .addKey(management.getPropertyKey("current"))
                .buildMixedIndex(graphCreds.getIndex_index_name());

我在此图上运行的查询是,

g.V().hasLabel("seeker").has("p_uuid", <p_uuid>).outE("worked").as_("e1").inV().inE("worked").as_("e2")\
                .outV().as_("b").outE("worked").where(inV().hasLabel("company").has("company_name", <company_name>)).has("current", 1)\
                .where("e1", lt("e2")).by("start_date").by("end_date").where("e1", gt("e2")).by("end_date").by("start_date")\
                .select("e1", "e2", "b").range_(0,10).toList()

我们可以说,我在 gremlin 查询中使用了 4 个属性,

  • p_uuid
  • 公司名称
  • 结束日期
  • 开始日期

并且所有 4 个都在综合索引和混合索引中建立索引。那为什么会超时。

我也检查了机器性能指标,机器没有使用 50% 的 CPU。如果机器有 CPU 能力,那么为什么 Janusgraph 不利用它?

我已将所有 Janusgraph 配置保留为默认值。

我还不确定的一件事是,当我对上述查询进行分析时,它仅命中

seeker
索引(从查询的第一部分开始),之后它不应该命中
company
索引也是如此?以及
start_date
end_date
索引?

janusgraph
1个回答
0
投票

它仅命中搜索者索引(从查询的第一部分开始),之后它不应该也命中公司索引吗?还有 start_date 和 end_date 索引?

全局索引(几乎)仅在查询的第一步使用。如果你想加速edge遍历,你需要使用Vertex Centric Indexes。

参考资料:

  1. https://li-boxuan.medium.com/janusgraph-deep-dive-part-2-demystify-indexing-d26e71edb386
  2. https://li-boxuan.medium.com/janusgraph-deep-dive-part-3-speed-up-edge-queries-3b9eb5ba34f8
  3. https://docs.janusgraph.org/schema/index-management/index-performance/#vertex-centric-indexes
© www.soinside.com 2019 - 2024. All rights reserved.