MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / optimize

Function optimize

nodedb/src/engine/graph/pattern/optimizer.rs:27–31  ·  view source on GitHub ↗

Optimize a MatchQuery by reordering triples for better join selectivity. Modifies the query in-place. Each PatternChain's triples are reordered so that the most selective (lowest edge count) triple executes first. Triples with already-bound variables (from earlier triples in the same chain) are preferred as they produce fewer intermediate results.

(query: &mut MatchQuery, csr: &CsrIndex)

Source from the content-addressed store, hash-verified

25/// Triples with already-bound variables (from earlier triples in the same
26/// chain) are preferred as they produce fewer intermediate results.
27pub fn optimize(query: &mut MatchQuery, csr: &CsrIndex) {
28 for clause in &mut query.clauses {
29 optimize_clause(clause, csr);
30 }
31}
32
33fn optimize_clause(clause: &mut MatchClause, csr: &CsrIndex) {
34 for chain in &mut clause.patterns {

Callers 2

executeFunction · 0.50

Calls 1

optimize_clauseFunction · 0.85

Tested by 1