Repository navigation
feat(graph): Query Rewriting for Graph Optimization (Issue #250) - #4621
Merged
makr-code merged 3 commits intoApr 13, 2026
Merged
Conversation
14 tasks
… (Issue #250) Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/9ecbeda9-206a-44f8-b0e6-f6abcd23819f Co-authored-by: makr-code <[email protected]>
Copilot
AI
changed the title
[WIP] Implement query rewriting for graph optimization
feat(graph): Query Rewriting for Graph Optimization (Issue #250)
Apr 13, 2026
makr-code
marked this pull request as ready for review
April 13, 2026 13:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
GraphQueryRewriter— an automatic, rule-based JSON plan transformer for graph query optimization. Operates on a pure JSON plan representation with no DB I/O; thread-safe and deterministic. Applies rules to a fixed point (max 5 iterations) with an optional wall-clock time budget.New:
GraphQueryRewriterFive rewrite rules:
PREDICATE_PUSHDOWN/PRUNE_EARLYvertex_filters→prune_conditionsongraph_traversalnodes; pushesfilter_scanpredicates into child traversalCOMMON_SUBEXPRESSIONgraph_traversalsub-trees, hoists tolet_scopebinding, replaces duplicates withrefnodesJOIN_REORDERINGtraversal_joinoperands when right side has lower heuristic cardinality (depth × filter count)MATERIALIZED_VIEWuse_materialized_view: truefor multi-access patterns; aggressive mode tags any depth ≥ 2QUERY_DECOMPOSITIONmulti_traversal(multi-start fan-out) intoparallel_subqueriesfor concurrent executionAdditional API:
estimateSpeedup(),explainRewrites(),addCustomRule()/clearCustomRules(),RewriteConfig(selective rule enable, aggressive mode, time limit), factory helpers (makeTraversalPlan,makeJoinPlan,makeMultiTraversalPlan, etc.).Files
include/graph/graph_query_rewriter.h,src/graph/graph_query_rewriter.cpptests/test_graph_query_rewriter.cpp— 38 unit tests (all acceptance criteria)cmake/CMakeLists.txt— adds source to build;tests/CMakeLists.txt— addstest_graph_query_rewriterstandalone CTest targetsrc/graph/ROADMAP.md(Phase 5 ✅),src/graph/FUTURE_ENHANCEMENTS.md,src/ROADMAP.md(row 250 ✅)Linked Issues
Closes #250
Type of Change
Breaking Change Checklist
VERSIONandCMakeLists.txtdocs/migration/### Removed/### Changedsection updatedTesting
38 unit tests in
tests/test_graph_query_rewriter.cppcovering all acceptance criteria: per-rule correctness,RewriteStatspopulation,estimateSpeedup > 1.0after rewrites,explainRewritescontent, custom rule hook, selective rule enablement viaRewriteConfig::enabled_rules, and time-limit escape hatch.📚 Research & Knowledge (wenn applicable)
/docs/research/angelegt?/docs/research/implementation_influence/eingetragen?Relevante Quellen:
Checklist
[Unreleased]