dosubot[bot] commented on issue #2869: URL: https://github.com/apache/incubator-hugegraph/issues/2869#issuecomment-3280326499
<!-- Answer --> 你的确是主键 id 起点查询,GraphStep(vertex,[id]) 这一步不需要二级索引,性能也不会有瓶颈。但你的 Gremlin 查询后续包含了多层 outE/inE/bothE 遍历和复杂 where/filter 条件(如 country_code、status 等),这些步骤在 HugeGraph 1.5.0(hstore 架构)下如果没有二级索引,依然会导致全表扫描和大量数据在 JVM 内存中过滤,极大拖慢查询。 代码实现上,HugeVertexStep、TraversalFilterStep、AndStep 等遍历步骤会先构造后端查询(GraphTransaction.constructEdgesQuery),再用 FilterIterator 在内存中过滤属性。没有索引时,每层都要拉取大量边/点数据,尤其在 50 亿点/边规模下,性能会指数级下降,硬件再强也无法弥补索引缺失带来的全表扫描和内存压力(详见[代码分析](https://github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/HugeTraverser.java))。 社区和官方 issue 也明确指出,所有 where/has/filter 查询条件都必须有二级或范围索引覆盖,才能避免全表扫描,提升多层遍历和复杂过滤的性能,尤其在 1.5.0 这种分布式后端下更为关键([参考](https://github.com/apache/incubator-hugegraph/issues/2836))。 建议优先给所有高频过滤属性(如 country_code、status、multi_scene_mark 等)补充二级索引,索引生效后,后续多层遍历和过滤才会走索引,性能才能恢复到合理水平。否则即使主键起点,后续链式遍历和属性过滤依然会拖慢整体查询。 如需具体索引创建语句或进一步分析执行计划的瓶颈环节,可以继续补充说明。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/bdcf4ed8-5cb1-407f-90d8-1a16fa67a1e1?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/bdcf4ed8-5cb1-407f-90d8-1a16fa67a1e1?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/bdcf4ed8-5cb1-407f-90d8-1a16fa67a1e1?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/bdcf4ed8-5cb1-407f-90d8-1a16fa67a1e1?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bdcf4ed8-5cb1-407f-90d8-1a16fa67a1e1?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/bdcf4ed8-5cb1-407f-90d8-1a16fa67a1e1?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bdcf4ed8-5cb1-407f-90d8-1a16fa67a1e1?feedback_type=other)</sup> [](https://app.dosu.dev/e5e246fa-a522-4d8a-ab3c-e2588b5b501b/ask?utm_source=githu b) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-hugegraph/issues/2869) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@hugegraph.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@hugegraph.apache.org For additional commands, e-mail: issues-h...@hugegraph.apache.org