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