GitHub user dosubot[bot] added a comment to the discussion: Why is the cache not used when querying vertices through an index?
<!-- Greeting --> @xulzee Hello there! I'm here to assist you with any bugs, questions, or contributions. Let's tackle this issue together! <!-- Answer --> The cache is not used when querying vertices through an index, such as in the query `g.V().hasLabel("server")`, because this query uses `indexQuery`, which directly interacts with the index to retrieve the vertices. The `indexQuery` method is optimized for quick lookups using the index, bypassing the need for caching. In contrast, the query `g.V('1:xx').bothE().dedup()` uses `CachedGraphTransaction`, which benefits from caching mechanisms. This is because such queries involve traversals and deduplication operations that can be optimized by caching previously retrieved data to avoid redundant database accesses. The `CachedGraphTransaction` class manages caching for vertices and edges, allowing traversal queries to utilize cached data when available, thus enhancing performance by reducing the need for repeated backend queries <sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphIndexTransaction.java)</sup><sup>[[2]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedGraphTransaction.java)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/22d62738-0494-4d1c-9879-88fcb6693d02?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/22d62738-0494-4d1c-9879-88fcb6693d02?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/22d62738-0494-4d1c-9879-88fcb6693d02?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/22d62738-0494-4d1c-9879-88fcb6693d02?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/22d62738-0494-4d1c-9879-88fcb6693d02?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/22d62738-0494-4d1c-9879-88fcb6693d02?feedback_type=other)</sup> GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2713#discussioncomment-11661405 ---- This is an automatically sent email for dev@hugegraph.apache.org. To unsubscribe, please send an email to: dev-unsubscr...@hugegraph.apache.org